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

Avoid misdetecting global Linux Python as virtualenv #197

Merged
merged 3 commits into from
Mar 24, 2025

Conversation

elprans
Copy link
Contributor

@elprans elprans commented Mar 13, 2025

/usr/bin on Linux might contain unrelated activate.* binaries
which would make is_virtualenv_dir mistake it for a virtualenv:

Environment (VirtualEnv)
   Executable  : /usr/bin/python
   Symlinks    : "/usr/bin/python"

Environment (VirtualEnv)
   Executable  : /bin/python
   Symlinks    : "/bin/python"

Environment (VirtualEnv)
   Executable  : /usr/bin/python3
   Symlinks    : "/usr/bin/python3"

Environment (VirtualEnv)
   Executable  : /bin/python3
   Symlinks    : "/bin/python3"

Environment (VirtualEnv)
   Executable  : /usr/bin/python3.10
   Symlinks    : "/usr/bin/python3.10"

Environment (VirtualEnv)
   Executable  : /bin/python3.10
   Symlinks    : "/bin/python3.10"

Environment (VirtualEnv)
   Executable  : /usr/bin/python3.11
   Symlinks    : "/usr/bin/python3.11"

This fix reduces the likelihood of this happening by excluding the
common bin directories as well as tightening the activate test
to avoid matching binaries like activate-ssh-agent.

`/usr/bin` on Linux might contain unrelated 'activate.*` binaries
which would make `is_virtualenv_dir` mistake it for a virtualenv:

	Environment (VirtualEnv)
	   Executable  : /usr/bin/python
	   Symlinks    : "/usr/bin/python"

	Environment (VirtualEnv)
	   Executable  : /bin/python
	   Symlinks    : "/bin/python"

	Environment (VirtualEnv)
	   Executable  : /usr/bin/python3
	   Symlinks    : "/usr/bin/python3"

	Environment (VirtualEnv)
	   Executable  : /bin/python3
	   Symlinks    : "/bin/python3"

	Environment (VirtualEnv)
	   Executable  : /usr/bin/python3.10
	   Symlinks    : "/usr/bin/python3.10"

	Environment (VirtualEnv)
	   Executable  : /bin/python3.10
	   Symlinks    : "/bin/python3.10"

	Environment (VirtualEnv)
	   Executable  : /usr/bin/python3.11
	   Symlinks    : "/usr/bin/python3.11"

This fix reduces the likelihood of this happening by excluding the
common `bin` directories as well as tightening the `activate` test
to avoid matching binaries like `activate-ssh-agent`.
@vs-code-engineering vs-code-engineering bot added this to the March 2025 milestone Mar 23, 2025
@DonJayamanne DonJayamanne merged commit 871e179 into microsoft:main Mar 24, 2025
20 checks passed
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.

3 participants