-
Notifications
You must be signed in to change notification settings - Fork 37
Open
Labels
bugIssue identified by VS Code Team member as probable bugIssue identified by VS Code Team member as probable bugneeds PR
Description
Problem
The Pipenv implementation doesn't check the WORKON_HOME and XDG_DATA_HOME environment variables when locating centralized virtual environments.
Background
Pipenv can store virtualenvs in multiple locations:
WORKON_HOME(if set) - commonly shared with virtualenvwrapperXDG_DATA_HOME/virtualenvs(Linux, if XDG_DATA_HOME is set)~/.local/share/virtualenvs(Linux/macOS default)~/.virtualenvs(alternative location)
Current State
The extension relies entirely on PET server for discovery and doesn't explicitly support these environment variables in its own logic.
PET Server Reference
The PET server properly checks these in pet-pipenv/src/lib.rs:
fn get_pipenv_virtualenv_dirs(env_vars: &EnvVariables) -> Vec<PathBuf> {
let mut dirs: Vec<PathBuf> = vec![];
// WORKON_HOME can be used by pipenv as well
if let Some(workon_home) = &env_vars.workon_home {
if workon_home.exists() {
dirs.push(norm_case(workon_home));
}
}
// XDG_DATA_HOME/virtualenvs (common on Linux)
if let Some(xdg_data_home) = &env_vars.xdg_data_home {
let xdg_venvs = PathBuf::from(xdg_data_home).join("virtualenvs");
if xdg_venvs.exists() {
dirs.push(norm_case(xdg_venvs));
}
}
// ...
}Suggested Fix
If the extension needs to perform any local discovery or validation, it should honor these environment variables:
function getPipenvVirtualenvDirs(): string[] {
const dirs: string[] = [];
// WORKON_HOME
const workonHome = process.env.WORKON_HOME;
if (workonHome && fs.existsSync(workonHome)) {
dirs.push(workonHome);
}
// XDG_DATA_HOME/virtualenvs
const xdgDataHome = process.env.XDG_DATA_HOME;
if (xdgDataHome) {
const xdgVenvs = path.join(xdgDataHome, 'virtualenvs');
if (fs.existsSync(xdgVenvs)) {
dirs.push(xdgVenvs);
}
}
// Default locations...
return dirs;
}Impact
Users with custom WORKON_HOME or XDG_DATA_HOME configurations may have pipenv environments that aren't discovered or correctly associated with projects.
Affected File
src/managers/pipenv/pipenvUtils.ts
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugIssue identified by VS Code Team member as probable bugIssue identified by VS Code Team member as probable bugneeds PR