Skip to content

Fix PyEnv section endlessly spinning when pyenv is not installed #438

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions src/managers/pyenv/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,14 @@ export async function registerPyenvFeatures(
const api: PythonEnvironmentApi = await getPythonApi();

try {
await getPyenv(nativeFinder);

const mgr = new PyEnvManager(nativeFinder, api);
disposables.push(mgr, api.registerEnvironmentManager(mgr));
const pyenv = await getPyenv(nativeFinder);

if (pyenv) {
const mgr = new PyEnvManager(nativeFinder, api);
disposables.push(mgr, api.registerEnvironmentManager(mgr));
} else {
traceInfo('Pyenv not found, turning off pyenv features.');
}
} catch (ex) {
traceInfo('Pyenv not found, turning off pyenv features.', ex);
}
Expand Down
7 changes: 5 additions & 2 deletions src/managers/pyenv/pyenvUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,11 @@ export async function refreshPyenv(
.filter((e) => !isNativeEnvInfo(e))
.map((e) => e as NativeEnvManagerInfo)
.filter((e) => e.tool.toLowerCase() === 'pyenv');
pyenv = managers[0].executable;
await setPyenv(pyenv);

if (managers.length > 0) {
pyenv = managers[0].executable;
await setPyenv(pyenv);
}
}

const envs = data
Expand Down