mskyaxl / wsl-terminal

Terminal emulator for Windows Subsystem for Linux (WSL)
MIT License
3.12k stars 158 forks source link

command in "~/.local/bin" can not be activated #154

Closed hillerliao closed 4 years ago

hillerliao commented 5 years ago

command in ~/.local/bin can not be activated.

for example , /home/{whoami}/.local/bin/jupyter exists , but when I ranjupyter notebook, I was told jupyter: command not found

when I ran the same command in bash.exe windows, everything was OK.

feryardiant commented 4 years ago

That's mean your ~/.local/bin is not included in your $PATH. Run echo $PATH to verify.

Easy fix, add this in your .bashrc to check if $HOME/.local/bin directory exists but not available in your $PATH, then add it to $PATH.

[[ -d $HOME/.local/bin && -z "${PATH##*$HOME/.local/bin*}" ]] || PATH=$PATH:$HOME/.local/bin

I've also had experience that for some reason /sbin, /usr/sbin & /usr/local/sbin are not available in my $PATH

for sbin_dir in {/sbin,/usr/sbin,/usr/local/sbin}; do
        [[ -d $sbin_dir && -z "${PATH##*$sbin_dir*}" ]] || PATH=$PATH:$sbin_dir
done
unset sbin_dir

And I am not sure if this issue have any correlation with any terminal emulator including wsl-terminal.

mskyaxl commented 4 years ago

command in ~/.local/bin can not be activated.

for example , /home/{whoami}/.local/bin/jupyter exists , but when I ranjupyter notebook, I was told jupyter: command not found

when I ran the same command in bash.exe windows, everything was OK.

Are you running wsl-terminal with login shell or not? By default $HOME/bin:$HOME/.local/bin is added to $PATH in .profile and this is done only if you start the shell with -l (you can also use open-wsl-login shortcut which is created with 4-create-start-menu-shortcut-login-shell.js)

mskyaxl commented 4 years ago

@hillerliao, any feedback on this?

hillerliao commented 4 years ago

sorry I delete the wsl .