You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Today I learned that on macOS, shells run /usr/libexec/path_helper to prepend entries from /etc/paths{,.d} to the PATH. They only do so when they're invoked as login shells, because otherwise, this would override PATH customizations configured by users whenever they launch a subshell (fish only fixed this relatively recently).
Unfortunately, the Jupyter terminal always launches shells as login:
# Enable login mode - to automatically source the /etc/profile script
ifos.name!='nt':
shell.append('-l')
This means that if the user has modified their PATH because of tools like virtualenv or pyenv, these entries will be demoted in shells launched by the Jupyter terminal on macOS, and the system Python in /usr/bin/python will take precedence. (Other binaries will also be affected of course, but Python is likely to be a prominent problem for Jupyter users.)
Running the shell as login makes sense in remote server setups where Jupyter is not launched from an existing shell session, which has already presumably sourced /etc/profile, but from some kind of spawner. But it doesn't make sense when launched from a shell on a local machine.
One possible way to address this would be to only run shells as login when they're not nested, which can be detected via the SHLVL env var:
Today I learned that on macOS, shells run
/usr/libexec/path_helper
to prepend entries from/etc/paths{,.d}
to thePATH
. They only do so when they're invoked as login shells, because otherwise, this would overridePATH
customizations configured by users whenever they launch a subshell (fish only fixed this relatively recently).Unfortunately, the Jupyter terminal always launches shells as login:
notebook/notebook/terminal/__init__.py
Lines 24 to 26 in 43df5af
This means that if the user has modified their
PATH
because of tools like virtualenv or pyenv, these entries will be demoted in shells launched by the Jupyter terminal on macOS, and the system Python in/usr/bin/python
will take precedence. (Other binaries will also be affected of course, but Python is likely to be a prominent problem for Jupyter users.)Running the shell as login makes sense in remote server setups where Jupyter is not launched from an existing shell session, which has already presumably sourced
/etc/profile
, but from some kind of spawner. But it doesn't make sense when launched from a shell on a local machine.One possible way to address this would be to only run shells as login when they're not nested, which can be detected via the
SHLVL
env var:dlukes@2786c15
The text was updated successfully, but these errors were encountered: