systemctl icon indicating copy to clipboard operation
systemctl copied to clipboard

Does not work on NixOS

Open ChocolateLoverRaj opened this issue 1 year ago • 4 comments

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).

ChocolateLoverRaj avatar Aug 11 '24 01:08 ChocolateLoverRaj

imagen https://crates.io/crates/systemctl

busslina avatar Aug 11 '24 13:08 busslina

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?

ChocolateLoverRaj avatar Aug 11 '24 16:08 ChocolateLoverRaj

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?

Your proposal is logic. I don't know if the lib maintainers have a good reason to not do that.

busslina avatar Aug 11 '24 16:08 busslina

You can also do


    let systemctl = SystemCtl::builder()
        .path("/run/current-system/sw/bin/systemctl".into())
        .additional_args(Vec::new())
        .build();

Muxutruk2 avatar Jun 25 '25 18:06 Muxutruk2