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

PR: User environment variables to take precedence for IPython Console kernel #23761

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mrclary
Copy link
Contributor

@mrclary mrclary commented Feb 18, 2025

Description of Changes

Ensure that user environment variables supersede Spyder runtime environment variables when starting the IPython Console kernel.

Issue(s) Resolved

Fixes #23711

@mrclary mrclary self-assigned this Feb 18, 2025
@mrclary mrclary added this to the v6.0.5 milestone Feb 18, 2025
@mrclary mrclary force-pushed the issue-23711-path-env-var branch from 53aeaf7 to 9ddfe74 Compare February 25, 2025 17:35
@mrclary
Copy link
Contributor Author

mrclary commented Feb 25, 2025

@spyder-ide/core-developers,
So I've run into an issue on this PR for Windows. The IPython console tests fail because a user-defined PATH variable clobbers the system-defined PATH variable. I see the same symptoms as #23582, so it may be related.

I'd like your feedback because I think we should clarify what get_user_environment_variables should do on all platforms.

Currently, get_user_environment_variables retrieves both "system" and "user" variables on posix systems, but only "user" variables on Windows. "User" variables will clobber "system" variables on all platforms except for PATH and PYTHONPATH on Windows. These seem to be an exception in which "system" and "user" values are concatenated. This is a problem when these are defined in the "system" variables and when using winreg to get user variables from HKEY_CURRENT_USER since the "system" values will not be retrieved.

In the specific case of this PR and possibly #23582, if the PATH environment variable sent to kernelspec is missing critical system paths for whatever reason, then the 'chcp' is not recognized as an internal or external command error will certainly result.

So should we also retrieve the environment variables from HKEY_LOCAL_MACHINE and concatenate the PATH and PYTHONPATH variable values? Note this would have implications for set_user_env.

@mrclary
Copy link
Contributor Author

mrclary commented Feb 26, 2025

Also, should we consider using a subprocess script like we do for posix? Getting user (or system) variables from the registry does not resolve variable references, e.g. %SystemRoot%\system32 or %HOMEPATH%\some\directory.

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

Successfully merging this pull request may close these issues.

PATH user environment variable is incorrectly transmitted to the IPython Console for macOS shortcuts
1 participant