Add platform-specific default paths for Poetry cache and virtualenvs#1218
Merged
karthiknadig merged 2 commits intomainfrom Feb 19, 2026
Merged
Add platform-specific default paths for Poetry cache and virtualenvs#1218karthiknadig merged 2 commits intomainfrom
karthiknadig merged 2 commits intomainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates Poetry environment discovery to use platform-correct default cache/virtualenvs locations and adds logic to resolve Poetry’s {cache-dir} placeholder (addressing issues #1182 and #1184).
Changes:
- Add
getDefaultPoetryCacheDir()/getDefaultPoetryVirtualenvsPath()and use them as fallbacks for Poetry virtualenv discovery. - Add
{cache-dir}placeholder resolution viapoetry config cache-dir. - Add
isMac()helper and unit tests for the new default-path helpers.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/managers/poetry/poetryUtils.ts | Implements platform-specific defaults and {cache-dir} resolution for Poetry virtualenv paths. |
| src/common/utils/platformUtils.ts | Adds isMac() platform helper. |
| src/test/managers/poetry/poetryUtils.unit.test.ts | Adds unit tests for the new default Poetry cache/virtualenv path helpers. |
Comments suppressed due to low confidence (2)
src/managers/poetry/poetryUtils.ts:210
resolveVirtualenvsPath()can return the original string containing{cache-dir}when it can’t resolve the placeholder.getPoetryVirtualenvsPath()then persists that unresolved value to workspace state, which can permanently break discovery until the state is cleared. Consider returningundefined(or falling back togetDefaultPoetryVirtualenvsPath()) when the placeholder can’t be resolved, and only caching paths that are resolved (no{…}) and absolute.
This issue also appears on line 303 of the same file.
// Poetry might return the path with placeholders like {cache-dir}
// Resolve the placeholder if present
if (venvPath.includes('{cache-dir}')) {
poetryVirtualenvsPath = await resolveVirtualenvsPath(poetry, venvPath);
} else if (path.isAbsolute(venvPath)) {
poetryVirtualenvsPath = venvPath;
} else {
// Not an absolute path and no placeholder, use platform-specific default
poetryVirtualenvsPath = getDefaultPoetryVirtualenvsPath();
}
if (poetryVirtualenvsPath) {
await state.set(POETRY_VIRTUALENVS_PATH_KEY, poetryVirtualenvsPath);
return poetryVirtualenvsPath;
}
src/managers/poetry/poetryUtils.ts:311
- The “last resort” branch returns
virtualenvsPathunchanged even though it still contains{cache-dir}and is likely unusable. Since callers treat a non-empty string as valid and may cache it, it would be safer to returnundefined/throw, or to fall back togetDefaultPoetryVirtualenvsPath()so the rest of the code doesn’t propagate an invalid path.
// Fall back to platform-specific default cache dir
const defaultCacheDir = getDefaultPoetryCacheDir();
if (defaultCacheDir) {
return virtualenvsPath.replace('{cache-dir}', defaultCacheDir);
}
// Last resort: return the original path (will likely not be valid)
return virtualenvsPath;
}
ad72595 to
3c8ba72
Compare
2149284 to
bea873e
Compare
…lder and improve path resolution
bea873e to
6c28cab
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Comments suppressed due to low confidence (1)
src/test/features/projectManager.initialize.unit.test.ts:352
- Same formatting issue here: add spaces inside the braces for readability (or revert to brace-less one-liners if preferred).
if (key === 'pythonProjects') {return [] as unknown as T;}
if (key === 'defaultEnvManager') {return 'ms-python.python:venv' as T;}
return defaultValue;
DonJayamanne
approved these changes
Feb 19, 2026
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 #1182
Fixes #1184