tomerfiliba / plumbum

Plumbum: Shell Combinators
https://plumbum.readthedocs.io
MIT License
2.81k stars 183 forks source link

Directories in PATH should be expanded #518

Closed rmillet-rs closed 4 years ago

rmillet-rs commented 4 years ago

Hello,

With plumbum 1.6.9, when running a local command, it fails because the command is not found in PATH.

The failing directory in PATH contains a ~ for user expansion.

plumbum.commands.processes.CommandNotFound: ('mybin', [<LocalPath /usr/local/sbin>, <LocalPath /usr/local/bin>, <LocalPath /usr/sbin>, <LocalPath /usr/bin>, <LocalPath /sbin>, <LocalPath /bin>, <LocalPath ~/mydir>])

If I put the expanded directory /home/user/mydir in PATH, it works as expected.

Calling the binary from my shell (bash) works.

AndydeCleyre commented 4 years ago

I don't think your PATH should actually have a ~ at all.

AFAIU, you may use an unquoted ~ when adding an item to PATH with bash or zsh, because the shell will replace that unquoted ~ with the value of $HOME, before assignment.

How are you setting that PATH in the first place?

rmillet-rs commented 4 years ago

Here is how I export it:

echo $SHELL
/bin/bash
export PATH="${PATH}:~/mybin"
echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:~/mybin

I did a few tests, it works on bash but not on busybox, dash, ksh or zsh. So it seems to be a bash-only feature.

So, I close this issue.

piotr-dobrogost commented 4 years ago

I don't think your PATH should actually have a ~ at all.

Yep, more info at https://unix.stackexchange.com/q/154281/5355