Skip to content

feat: add WORKON_HOME and XDG_DATA_HOME support for pipenv (Fixes #1185)#1249

Merged
karthiknadig merged 1 commit intomicrosoft:mainfrom
karthiknadig:feature/issue-1185
Feb 19, 2026
Merged

feat: add WORKON_HOME and XDG_DATA_HOME support for pipenv (Fixes #1185)#1249
karthiknadig merged 1 commit intomicrosoft:mainfrom
karthiknadig:feature/issue-1185

Conversation

@karthiknadig
Copy link
Member

Adds support for WORKON_HOME and XDG_DATA_HOME environment variables when discovering pipenv virtualenv directories.

Changes

  • Added getPipenvVirtualenvDirs() function to pipenvUtils.ts that returns directories where pipenv virtualenvs may be stored
  • Added comprehensive unit tests for the new function
  • Added verbose tracing for debugging discovery issues

Discovery Priority

The function checks these locations in priority order:

  1. WORKON_HOME (if set and exists) - commonly shared with virtualenvwrapper
  2. XDG_DATA_HOME/virtualenvs (if XDG_DATA_HOME is set and path exists)
  3. ~/.local/share/virtualenvs (Linux/macOS default)
  4. ~/.virtualenvs (Windows default)

Testing

  • 8 unit tests covering all env var scenarios, priority ordering, deduplication, and tilde expansion
  • Tests use real temp directories for filesystem operations (since fs.existsSync cannot be stubbed)
  • Cross-platform compatible (tested on Windows, patterns work for Linux/macOS)

Fixes #1185

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 adds support for WORKON_HOME and XDG_DATA_HOME environment variables when discovering pipenv virtualenv directories. The implementation adds a new utility function that mirrors the logic from the PET (Python Environment Tools) server to ensure consistent environment discovery across platforms.

Changes:

  • Added getPipenvVirtualenvDirs() function to centralize pipenv virtualenv directory discovery logic
  • Added comprehensive unit tests covering all environment variable scenarios, priority ordering, and cross-platform behavior
  • Added verbose logging for debugging pipenv discovery issues

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/managers/pipenv/pipenvUtils.ts Adds getPipenvVirtualenvDirs() function that checks WORKON_HOME, XDG_DATA_HOME, and platform-specific default paths in priority order
src/test/managers/pipenv/pipenvUtils.getPipenvVirtualenvDirs.unit.test.ts Comprehensive unit tests (8 test cases) covering environment variable scenarios, deduplication, tilde expansion, and cross-platform behavior

@karthiknadig karthiknadig added bug Issue identified by VS Code Team member as probable bug labels Feb 19, 2026
@karthiknadig karthiknadig enabled auto-merge (squash) February 19, 2026 03:04
@karthiknadig karthiknadig merged commit 7dfce4b into microsoft:main Feb 19, 2026
50 of 51 checks passed
@karthiknadig karthiknadig deleted the feature/issue-1185 branch February 19, 2026 05:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Issue identified by VS Code Team member as probable bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Pipenv: Missing support for WORKON_HOME and XDG_DATA_HOME environment variables

2 participants

Comments