Is there a reason why toolbox run which <executable> is not searching my PATH?
$ toolbox run which not_there
which: no not_there in (/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin)
The paths searched seem missing my custom PATH from .bashrc.
$ toolbox run echo $PATH
/home/returntrip/.local/bin:/home/returntrip/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/var/lib/flatpak/exports/bin:/home/returntrip/development/android-studio/bin:/home/returntrip/development/flutter/bin:/home/returntrip/development/dart-sdk/bin
The PATH returned is correct
⬢$ which not_there
/usr/bin/which: no not_there in (/home/returntrip/.local/bin:/home/returntrip/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/home/returntrip/development/android-studio/bin:/home/returntrip/development/flutter/bin:/home/returntrip/development/dart-sdk/bin)
The paths searched do include my PATH paths sourced from .bashrc
⬢$ echo $PATH
/home/returntrip/.local/bin:/home/returntrip/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/home/returntrip/development/android-studio/bin:/home/returntrip/development/flutter/bin:/home/returntrip/development/dart-sdk/bin
The PATH matched the paths searched by which (as expected)
$ toolbox run echo $PATH
I think you want toolbox run printenv PATH.
I suspect the problem is that toolbox run cmd doesn't run in a bash shell so you just get the system PATH, though I haven't analyzed this carefully.
I guess a workaround would be to use env (eg toolbox run env PATH=$PATH cmd or an absolute path.
I think you want
toolbox run printenv PATH.
You must be right, cause printenv PATH returns the correct path same as the which "error". I guess `echo $PATH" spawns an interactive shell (or something similar) and the path echoed is my user's path.
The workaround seems working:
$toolbox run --container test env PATH=$PATH which fwefwerf
which: no fwefwerf in (/home/returntrip/.local/bin:/home/returntrip/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/var/lib/flatpak/exports/bin:/home/returntrip/development/android-studio/bin:/home/returntrip/development/flutter/bin:/home/returntrip/development/dart-sdk/bin)
Thanks @juhp
Most helpful comment
I think you want
toolbox run printenv PATH.I suspect the problem is that
toolbox run cmddoesn't run in a bash shell so you just get the system PATH, though I haven't analyzed this carefully.I guess a workaround would be to use
env(egtoolbox run env PATH=$PATH cmdor an absolute path.