Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

issue: Could not find Bash on NixOS while setting persist mode #26

Closed
igor-frolikov opened this issue Jun 6, 2022 · 5 comments
Closed
Assignees
Labels
bug Something isn't working

Comments

@igor-frolikov
Copy link

Subject of the issue

[igor@nixos:~]$ sudo bat -t 80
Charging threshold set.
Use sudo bat --persist to persist the setting between restarts.

[igor@nixos:~]$ sudo bat -p
Could not find Bash on your system.

NixOS uses Bash as default shell. Please, check your shell calls. Setting threshold works fine.

Your system

OS: NixOS 22.05 (Quokka) x86_64
Host: ASUSTeK COMPUTER INC. X513IA
Kernel: 5.15.43

Version

0.9 (Latest)

Steps to reproduce

No response

Expected behaviour

No response

Actual behaviour

No response

@igor-frolikov igor-frolikov added the bug Something isn't working label Jun 6, 2022
@igor-frolikov
Copy link
Author

igor-frolikov commented Jun 6, 2022

It seems, that you need to add another bash path to your services.go: "/run/current-system/sw/bin/bash"
is it possible to use just "bash" string instead of the full path?

@tshakalekholoane
Copy link
Owner

Thank you for pointing that out, @igor-frolikov. I think it has to be the full path because some of these are run before path variables are set. But that said, there is probably a better way to set it. Can you check if running command -v bash gives the right location for Bash on your system?

@igor-frolikov
Copy link
Author

igor-frolikov commented Jun 7, 2022

[igor@nixos:~]$ command -v bash
/run/current-system/sw/bin/bash

NixOS has different file structure. Here are almost all symlinks. The path is standard for all NixOS Linux systems.
Another idea is replacing "bash" by "sh". This way "bin/sh" will work fine.

@tshakalekholoane
Copy link
Owner

Here's a fix. Please let me know if it works.

@igor-frolikov
Copy link
Author

[igor@nixos:~/Downloads]$ sudo ./bat -c
100

[igor@nixos:~/Downloads]$ sudo ./bat -t 60
Charging threshold set.
Use sudo bat --persist to persist the setting between restarts.

[igor@nixos:~/Downloads]$ sudo ./bat -c
100

[igor@nixos:~/Downloads]$ sudo ./bat -p
2022/06/10 23:14:33 open /etc/systemd/system/bat-suspendthenhibernate.service: read-only file system

Actually NixOS would never allow to write to system files. Thank you for your efforts. I wrote a simple script for cron. Works perfect even on Arch. Just on NixOS I run cron job using NixOS way.

tshakalekholoane pushed a commit that referenced this issue Jun 12, 2022
Change the function that queries the location of the Bash shell on the
operating system to look inside of the $PATH environment variable
instead of defaulting to standard locations such as /bin/ and /usr/bin/
that maybe not be true for all Unix operating systems i.e. NixOS.

See #26.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants