F1bonacc1 / process-compose

Process Compose is a simple and flexible scheduler and orchestrator to manage non-containerized applications.
https://f1bonacc1.github.io/process-compose/
Apache License 2.0
1.22k stars 40 forks source link

`sudo: exec: command not found` #223

Closed RafaelKr closed 1 week ago

RafaelKr commented 4 weeks ago

Defect

This is a follow up to https://github.com/F1bonacc1/process-compose/issues/190#issuecomment-2259068786

Make sure that these boxes are checked before submitting your issue -- thank you!

Version of process-compose:

1.18.0 (same issue with 1.9.0)

OS environment:

Linux Mint 21.3 nix (Nix) 2.22.0

Steps or code to reproduce the issue:

With devenv

Without devenv

Expected result:

process-compose should ask for a password, then start caddy

Actual result:

process-compose asks for a password and then the caddy process fails with sudo: exec: command not found

F1bonacc1 commented 4 weeks ago

Hi @RafaelKr,

I cloned your repo and installed Caddy, but couldn't reproduce your issue. image

Can you please share the log? What is your $SHELL

RafaelKr commented 4 weeks ago

This is my Shell info: image

This is how it looks for me: image

This is the output of cat /nix/store/liy6ihhqf1mnr1ljlvcdhb3k43av8qbi-caddy:

#!/nix/store/a1s263pmsci9zykm5xcdf7x9rv26w6d5-bash-5.2p26/bin/bash
XDG_DATA_HOME="/path/to/process-compose-is-elevated-repro/.devenv/state/caddy/data" XDG_CONFIG_HOME="/path/to/process-compose-is-elevated-repro/.devenv/state/caddy/config" /nix/store/7ad29pl6dsmpjkphkv4q7n3pp63g3v7w-caddy-2.7.6/bin/caddy run  --config /nix/store/53zj25rq3h5vmlgddpdfih4mj856bl00-caddy-config.json
F1bonacc1 commented 4 weeks ago

Can you please share the process compose log?

RafaelKr commented 4 weeks ago

With devenv:

$ ~ cat /tmp/nix-shell.B8Upaf/process-compose-rafael.log                               
24-08-16 16:39:19.241 INF Process Compose v1.18.0
24-08-16 16:39:19.241 INF Loaded project from /nix/store/v41r99nfajsdybx2m11bxqz3qrfllvjn-process-compose.yaml
24-08-16 16:39:19.241 INF Global shell command: bash -c
24-08-16 16:39:19.241 INF start UDS http server listening /run/user/1000/devenv-a45632c/pc.sock
24-08-16 16:39:19.242 DBG Spinning up 2 processes. Order: ["caddy" "sleep"]
24-08-16 16:39:19.242 INF Started command=["bash","-c","sudo -S exec /nix/store/liy6ihhqf1mnr1ljlvcdhb3k43av8qbi-caddy"] process=caddy
24-08-16 16:39:19.242 INF Started command=["bash","-c","exec /nix/store/yljzwniixbw2vwyz8nn9dbr2vpslvsf1-sleep"] process=sleep
24-08-16 16:39:24.604 DBG Set password for elevated process caddy
24-08-16 16:39:24.608 INF Password accepted process=caddy
24-08-16 16:39:24.608 INF Exited exit_code=1 process=caddy

Without devenv:

$ ~ cat /tmp/process-compose-rafael.log                               
24-08-16 16:37:00.121 INF Process Compose v1.18.0
24-08-16 16:37:00.121 INF Loaded project from /home/rafael/coding/open-source/github.com/F1bonacc1/process-compose-is-elevated-repro/process-compose.yaml
24-08-16 16:37:00.121 INF Global shell command: bash -c
24-08-16 16:37:00.121 INF start http server listening :8080
24-08-16 16:37:00.121 DBG Spinning up 2 processes. Order: ["caddy" "sleep"]
24-08-16 16:37:00.122 INF Started command=["bash","-c","sleep 3600"] process=sleep
24-08-16 16:37:00.122 INF Started command=["bash","-c","sudo -S caddy run --config ./Caddyfile"] process=caddy
24-08-16 16:37:04.123 DBG Set password for elevated process caddy
24-08-16 16:37:04.134 INF Password accepted process=caddy
24-08-16 16:37:04.135 INF Exited exit_code=1 process=caddy
F1bonacc1 commented 4 weeks ago

I was trying to repro without devenv. What is the error when running without devenv? I see that it runs a different command, without exec.

RafaelKr commented 4 weeks ago

It's the same error. But I also have to say that it's still using caddy and process-compose from the /nix/store. Maybe I should try if I can also reproduce it when I really install both as system packages without nix. Although I won't have time to do it today.

F1bonacc1 commented 4 weeks ago

I was able to repro it with:

bash -c 'sudo exec echo $PATH'
sudo: exec: command not found

I am not sure why devenv adds exec. Are you sure you are having the same issue without devenv?

RafaelKr commented 4 weeks ago

Good catch! It's coming from here: https://github.com/cachix/devenv/blob/b285601679c7686f623791ad93a8e0debc322633/src/modules/process-managers/process-compose.nix#L60

And was introduced with this commit: https://github.com/cachix/devenv/commit/78766e0df9ba0ff1923511b288d0489ba2d3a077

I just could work around it by updating my devenv.nix: https://github.com/RafaelKr/process-compose-is-elevated-repro/commit/fa283f213976242d00cdb1260e2c581cea72f565

Looks like it's a bug for devenv.

Edit: There we go https://github.com/cachix/devenv/issues/1391

RafaelKr commented 2 weeks ago

A fix for devenv was merged: https://github.com/cachix/devenv/pull/1404

It'll be included in the next release probably.