Skip to content

Conversation

@eleanorjboyd
Copy link
Member

No description provided.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR enhances conda environment management by adding sourcing status detection and improving shell activation support. The changes introduce a new system to determine whether conda is already active in the current shell and provide better shell-specific activation commands.

  • Adds CondaSourcingStatus class to track conda initialization state
  • Refactors shell activation command generation to use sourcing information
  • Introduces detection of global and shell-specific conda activation scripts

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 7 comments.

File Description
src/managers/conda/main.ts Adds sourcing status construction and assignment to environment manager
src/managers/conda/condaUtils.ts Refactors shell activation logic to use sourcing status and removes duplicate code
src/managers/conda/condaSourcingUtils.ts New utility for detecting conda sourcing status and activation scripts
src/managers/conda/condaEnvManager.ts Adds sourcingInformation property to store sourcing status

@eleanorjboyd eleanorjboyd marked this pull request as ready for review August 8, 2025 20:21
@vs-code-engineering
Copy link

⚠️ This PR originates from a fork. Due to security restrictions, pipelines from forks are no longer triggered automatically. Learn more.

If the changes appear safe, you can manually trigger the pipeline by commenting /AzurePipelines run.

@anthonykim1
Copy link
Contributor

made an issue for better pwsh logs in future: #706

@eleanorjboyd eleanorjboyd merged commit 7b2fb86 into microsoft:main Aug 11, 2025
6 checks passed
@eleanorjboyd eleanorjboyd deleted the everything-bagel branch August 11, 2025 22:45
eleanorjboyd added a commit to eleanorjboyd/vscode-python-environments that referenced this pull request Aug 12, 2025
eleanorjboyd added a commit that referenced this pull request Oct 8, 2025
Implementing better PowerShell version logging for activation debugging
as requested in issue #706.

The issue stems from the PR review comment
(#693 (comment))
suggesting that logging PowerShell version information would be valuable
for debugging activation failures, especially given the differences
between Windows PowerShell 5.x and PowerShell 7+.

## Changes Made:
- [x] Analyze current PowerShell activation flow in pwshStartup.ts and
pwshEnvs.ts
- [x] Examine existing logging patterns and utilities
- [x] Test current build/compile state of project
- [x] Create utility function to detect PowerShell version via
`$PSVersionTable.PSVersion.Major`
- [x] Add PowerShell version logging to relevant activation code paths
- [x] Add version logging for both conda and non-conda activation
scenarios
- [x] Ensure logging follows existing patterns (traceInfo/traceVerbose)
- [x] Test changes and verify proper logging output
- [x] Use shorter -c flag instead of -Command for PowerShell commands

## Implementation Details:
1. **Added `getPowerShellVersion()` function** - Detects PowerShell
major version using `$PSVersionTable.PSVersion.Major` command with `-c`
flag
2. **Enhanced installation logging** - Now logs PowerShell version when
shells are detected (e.g., "SHELL: pwsh is installed (version 7)")
3. **Enhanced activation script error messages** - PowerShell errors now
include version info (e.g., "Failed to activate Python environment
(PowerShell 7): error details")

## Testing:
- All existing unit tests pass (128 passing)
- Code compiles successfully with no lint errors
- Manual testing confirms PowerShell version detection works correctly

These changes provide better diagnostic information for debugging
PowerShell activation issues without affecting existing functionality.

Fixes #706.

<!-- START COPILOT CODING AGENT TIPS -->
---

💬 Share your feedback on Copilot coding agent for the chance to win a
$200 gift card! Click
[here](https://survey3.medallia.com/?EAHeSx-AP01bZqG0Ld9QLQ) to start
the survey.

---------

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: eleanorjboyd <[email protected]>
NguyenCuong1989 referenced this pull request in NguyenCuong1989/vscode-python-environments Oct 23, 2025
NguyenCuong1989 pushed a commit to NguyenCuong1989/vscode-python-environments that referenced this pull request Oct 23, 2025
Implementing better PowerShell version logging for activation debugging
as requested in issue #706.

The issue stems from the PR review comment
(microsoft/vscode-python-environments#693 (comment))
suggesting that logging PowerShell version information would be valuable
for debugging activation failures, especially given the differences
between Windows PowerShell 5.x and PowerShell 7+.

## Changes Made:
- [x] Analyze current PowerShell activation flow in pwshStartup.ts and
pwshEnvs.ts
- [x] Examine existing logging patterns and utilities
- [x] Test current build/compile state of project
- [x] Create utility function to detect PowerShell version via
`$PSVersionTable.PSVersion.Major`
- [x] Add PowerShell version logging to relevant activation code paths
- [x] Add version logging for both conda and non-conda activation
scenarios
- [x] Ensure logging follows existing patterns (traceInfo/traceVerbose)
- [x] Test changes and verify proper logging output
- [x] Use shorter -c flag instead of -Command for PowerShell commands

## Implementation Details:
1. **Added `getPowerShellVersion()` function** - Detects PowerShell
major version using `$PSVersionTable.PSVersion.Major` command with `-c`
flag
2. **Enhanced installation logging** - Now logs PowerShell version when
shells are detected (e.g., "SHELL: pwsh is installed (version 7)")
3. **Enhanced activation script error messages** - PowerShell errors now
include version info (e.g., "Failed to activate Python environment
(PowerShell 7): error details")

## Testing:
- All existing unit tests pass (128 passing)
- Code compiles successfully with no lint errors
- Manual testing confirms PowerShell version detection works correctly

These changes provide better diagnostic information for debugging
PowerShell activation issues without affecting existing functionality.

Fixes #706.

<!-- START COPILOT CODING AGENT TIPS -->
---

💬 Share your feedback on Copilot coding agent for the chance to win a
$200 gift card! Click
[here](https://survey3.medallia.com/?EAHeSx-AP01bZqG0Ld9QLQ) to start
the survey.

---------

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: eleanorjboyd <[email protected]>
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.

2 participants