fix: skip terminal activation when there is no activate script - #1801
Open
Shubham Padkonde (Shubham-Padkonde) wants to merge 1 commit into
Open
Shubham Padkonde (Shubham-Padkonde) wants to merge 1 commit into
Shubham Padkonde (Shubham-Padkonde) wants to merge 1 commit into
Conversation
getShellActivationCommands() emitted `source <bin>/activate` for sh, bash, zsh, Git Bash, ksh and the "unknown" shell without checking that the script exists, unlike the other shells. For base interpreters that share the layout but are not virtual environments (for example `uv python install` toolchains), every new terminal then ran a failing `source` command. Only add these entries when `activate` exists, and treat an environment with an empty shell activation map as not activatable. Fixes microsoft#1775 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1775
Problem
When an interpreter's
bin/has noactivatescript,getShellActivationCommands(binDir)still emittedsource <bin>/activatefor sh, bash, zsh, Git Bash, ksh and theunknownfallback.uv python installtoolchains are an example: they're base interpreters, not virtual environments. Every new terminal then ran a failing command:The other shells (csh, fish, xonsh, nu, pwsh, cmd) were already gated on their script existing.
Fix
getShellActivationCommandsonly adds theactivate-based entries (unknown, sh, bash, Git Bash, zsh, ksh) when<binDir>/activateexists. This matches how the other shells are handled. Real venvs, pipenv and poetry environments always shipactivate, so they're unaffected.isActivatableEnvironmentnow requires a non-emptyshellActivationmap. It used to check only that the map existed, so an environment with no activation commands was still offered for activation (the terminal activate button and command-based auto-activation).Tests
utils.getShellActivationCommands.unit.test.ts:unknownactivation without anactivatescript, on non-Windows and on Windows;src/test/features/common/activation.unit.test.tscoversisActivatableEnvironment, including the empty-map case.activatefile they rely on.tsc+ mocha, Node 22):eslintandprettier --checkare clean on the changed files.I did not test this manually in VS Code with a real uv toolchain. The fix is covered by the unit tests above.
This change was written with help from an AI coding assistant (Claude Code). I reviewed and tested it as described above.
🤖 Generated with Claude Code