KEMBAR78
Add Python activate hooks into shell integration scripts by anthonykim1 · Pull Request #261094 · microsoft/vscode · GitHub
Skip to content

Conversation

@anthonykim1
Copy link
Contributor

@anthonykim1 anthonykim1 commented Aug 11, 2025

Resolves: #259637

Important things to note:

  • Update all four shell integration scripts (pwsh, zsh, bash, fish) ---> Done
  • Sanitize in process.ts and terminalSuggest.main.ts ---> Done
  • If activate returns non-zero (failed), we should prevent crash, catch exit code, and print to terminal
    ---> Findings: Try catch was not available for zsh, bash so using negate to prevent crash. Fish doesn't crash on eval
    ---> Try catch was available in pwsh
    ---> Done
  • Block other extension from modifying Python specific activate (Important -> Should do this as activate var is leading to code execution) ---> Done
  • Have * icon similar to terminal restored message. ---> Done
  • Sanitize and remove hard-coded vsc python env var in terminalEnv ---> Done
  • Clean-ups ---> Done?

@anthonykim1 anthonykim1 self-assigned this Aug 11, 2025
@anthonykim1 anthonykim1 requested a review from Tyriar August 12, 2025 05:23
@anthonykim1 anthonykim1 marked this pull request as ready for review August 12, 2025 05:23
@anthonykim1 anthonykim1 added this to the August 2025 milestone Aug 12, 2025
@anthonykim1
Copy link
Contributor Author

After this PR, will make an additional PR in env extension to make sure they have fallback to still activate in case env extension can't locate hooks from vscode shell integration scripts.

@anthonykim1 anthonykim1 marked this pull request as draft August 12, 2025 16:29
@anthonykim1
Copy link
Contributor Author

Here is how the * shows up for example (ofc, exit code will be different when it actually fails, just did this to show what UI would look like):
Screenshot 2025-08-12 at 11 42 33 PM

@anthonykim1 anthonykim1 marked this pull request as ready for review August 13, 2025 07:13
@anthonykim1 anthonykim1 requested a review from Tyriar August 13, 2025 07:14
@anthonykim1 anthonykim1 marked this pull request as draft August 13, 2025 16:34
@anthonykim1 anthonykim1 marked this pull request as ready for review August 13, 2025 16:48
@anthonykim1 anthonykim1 requested a review from Tyriar August 13, 2025 16:48
@anthonykim1 anthonykim1 marked this pull request as draft August 13, 2025 17:08
Tyriar
Tyriar previously approved these changes Aug 13, 2025
@anthonykim1 anthonykim1 marked this pull request as ready for review August 13, 2025 17:12
@anthonykim1 anthonykim1 requested a review from Tyriar August 13, 2025 17:12
@anthonykim1 anthonykim1 enabled auto-merge (squash) August 13, 2025 17:17
@anthonykim1 anthonykim1 merged commit a80fd70 into main Aug 13, 2025
18 checks passed
@anthonykim1 anthonykim1 deleted the anthonykim1/PythonActivateHooks branch August 13, 2025 17:40
anthonykim1 added a commit to microsoft/vscode-python-environments that referenced this pull request Aug 15, 2025
Issue related: microsoft/vscode#259637
Adapting to: microsoft/vscode#261094

FYI if activation fails when eval from shell integration scripts, we're
making it very obvious for them:
microsoft/vscode#261094 (comment)

TODO: Remove activation debris in shell init files for existing users. 

/cc @cwebster-99
@vs-code-engineering vs-code-engineering bot locked and limited conversation to collaborators Sep 27, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Inject Python activate hooks into vscode shell integration scripts

2 participants