Toolbox: Possible PATH issue for toolbox run?

Created on 26 Mar 2020  Â·  2Comments  Â·  Source: containers/toolbox

Is there a reason why toolbox run which <executable> is not searching my PATH?

Toolbox run behaviour

$ 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

Toolbox enter behaviour

⬢$ 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)

Most helpful comment

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

All 2 comments

$ 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

Was this page helpful?
0 / 5 - 0 ratings