randy3k / Terminus

Bring a real terminal to Sublime Text
https://packagecontrol.io/packages/Terminus
MIT License
1.39k stars 81 forks source link

PATH out of order in Terminus shell #190

Open alkalifly opened 4 years ago

alkalifly commented 4 years ago

Mac OSX user here, I apologize if this is a more general Sublime Text issue, but when I open a bash shell with Terminus, the elements of my PATH are not in the same order as they are with Terminal.app, Xterm, etc.

My .bashrc contains: export PATH=/Applications/MATLAB_R2019b.app/bin:$PATH followed by the "conda initialize" code block, so when I echo $PATH in Terminal.app, I get /Users/alkalifly/miniconda/bin:/Users/alkalifly/miniconda/condabin:/Applications/MATLAB_R2019b.app/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/TeX/texbin:/opt/X11/bin

But when I echo $PATH in a Terminus shell, I get /Applications/MATLAB_R2019b.app/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/TeX/texbin:/opt/X11/bin:/Users/alkalifly/miniconda/bin:/Users/alkalifly/miniconda/condabin:/Applications/MATLAB_R2019b.app/bin

You may notice that /Applications/MATLAB_R2019b.app/bin (added in my .bashrc) appears in duplicate, which is strange, but the problem is that the conda stuff (also added in my .bashrc) appears only once and is after /usr/bin so the shell uses the system python instead of the conda python. I still see the (base) at the command prompt, indicating that the conda base environment is activated, but which python results in /usr./bin (which is not surprising, given the order of directories in my PATH.

randy3k commented 4 years ago

It is because Sublime Text gets the PATH from .bashrc already and Terminus sources the file again. But it usually doesn't cause any issues. Don't know why it changs the order of the paths.

alkalifly commented 4 years ago

Is there any way of checking whether the order changing is happening somewhere in Sublime vs. specifically in Terminus? And can you think of any possible ways of getting around it? I tried adding "args": { "shell_cmd": "export PATH='/Users/alkalifly/miniconda/bin:$PATH'", } to the key command for "terminus_open" but that just makes the Terminus shell disappear immediately after it launches.

z-aki commented 3 years ago

.. But it usually doesn't cause any issues.

.. so the shell uses the system python instead of the conda python.

That looks like an issue to me.

z-aki commented 3 years ago

This seems resolved by "shell_environment": false, sublime text preference.

timfjord commented 5 months ago

In my case (I use zsh and I had a problem with mise), even with "shell_environment": false I had to slightly update .bash_profile, as it was loaded even though my main shell was zsh