Does not work on NixOS
This code doesn't work:
const SYSTEMCTL_PATH: &str = "/usr/bin/systemctl";
With the error Error: No such file or directory (os error 2). This is because /usr/bin/systemctl does not exist in NixOS. systemctl is in the path in NixOS, so it would be better if the default path just called systemctl instead of assuming a certain path for systemctl (/usr/bin should be in path anyways).
https://crates.io/crates/systemctl
Why have to set a SYSTEMCTL_PATH variable when there is the PATH variable which is already set? Why not consider the PATH variable if SYSTEMCTL_PATH is not set?
Why have to set a
SYSTEMCTL_PATHvariable when there is thePATHvariable which is already set? Why not consider thePATHvariable ifSYSTEMCTL_PATHis not set?
Your proposal is logic. I don't know if the lib maintainers have a good reason to not do that.
You can also do
let systemctl = SystemCtl::builder()
.path("/run/current-system/sw/bin/systemctl".into())
.additional_args(Vec::new())
.build();