Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Forcing login shell in terminal overrides PATH on macOS #5247

Closed
dlukes opened this issue Feb 23, 2020 · 0 comments · Fixed by #5565
Closed

Forcing login shell in terminal overrides PATH on macOS #5247

dlukes opened this issue Feb 23, 2020 · 0 comments · Fixed by #5565

Comments

@dlukes
Copy link
Contributor

dlukes commented Feb 23, 2020

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
if os.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:

dlukes@2786c15

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant