-
Notifications
You must be signed in to change notification settings - Fork 205
Description
Trying to run nativelink on a NixOS system (or inside a Docker image created with nix' dockerTools) often fails to find executables.
For instance using
cpu_count: {
query_cmd: "nproc",
},fails with:
2025-11-14T15:22:21.945166Z INFO nativelink_worker::worker_utils: Spawning process, cmd: "nproc", property_name: "cpu_count"
at nativelink-worker/src/worker_utils.rs:66
in nativelink_worker::local_worker::run with shutdown_rx: broadcast::Receiver
in nativelink::worker with name: "worker_0"
2025-11-14T15:22:21.945372Z ERROR nativelink_worker::local_worker: Error, err: Error { code: NotFound, messages: ["No such file or directory (os error 2)", "Error executing property_name cpu_count command"] }
at nativelink-worker/src/local_worker.rs:649
in nativelink_worker::local_worker::run with shutdown_rx: broadcast::Receiver
in nativelink::worker with name: "worker_0"
Also trying to execute actions remotely fail with basically the same problem.
The reason for this is that commands are run using .env_clear(). On other systems that resets PATH to some default value (e.g. /usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin:.) but on NixOS these directories mostly just don't exist and hence the default PATH is just /no-such-path.
For remote execution, I can work around by using
additional_environment: {
PATH: {value: '${PATH}'},
},But that only works since the value is expanded explicitly from the environment and the query_cmd is not. Using an absolute path to nproc is not easily possible, as it depends on the nix store path of coreutils (inside a Docker image).
Clearing the environment when running an action is the right thing to do, but probably not during configuration. Thoughts?
IMO, setting up PATH explicitly is better than depending on some default values and the tools being installed in there. So instead of a hacky way of doing things, maybe there could be an explicit configuration that also is taken into account when caching? (not sure that's possible)