vscode extension incorrectly prepends /usr/bin to PATH (#56047, #41081) was fixed in extension 2.1.166

Status Fixed / completed
Reported on v2.1.166
Maintainer reply None cached
Activity 1 comment · opened Aug 6, 2026 · closed Aug 6, 2026

This is a follow-up note, not a new bug report. Both prior reports of this bug were closed as stale and are now locked, so there is no way to record the resolution on them.

Prior reports:

  • #41081 (closed as stale)
  • #56047 (refiling of the above, also closed as stale, now locked)

The bug: with claudeCode.usePythonEnvironment enabled (the default), the VS Code extension's Python-environment activation treated a system interpreter as a virtual environment. On Debian/Ubuntu, sys.prefix is /usr, so the extension set VIRTUAL_ENV=/usr and prepended /usr/bin to PATH for every session it spawned, shadowing /usr/local/bin and other user PATH entries. It did not reproduce when launching claude from a terminal.

It is fixed. The fix shipped in VS Code extension 2.1.166 and is still present in 2.1.223 (current latest).

The activation function now bails out unless the resolved interpreter is an actual venv or conda env:

// 2.1.166+
let s = n.environment?.type;
if (s !== "VirtualEnvironment" && s !== "Conda")
  return console.log(`Skipping Python env activation for environment type: ${s ?? "(none)"}`), e;
let o = n.executable?.sysPrefix || ...;
a.VIRTUAL_ENV = o;
a.PATH = `${bin}${delimiter}${l}`;

A system interpreter has no environment object, so it hits the "(none)" branch and PATH is left untouched.

For comparison, 2.1.165 had no such guard, and the surrounding minified code is otherwise identical (same path-module alias, same variable shapes), so this was a targeted change:

// 2.1.165 and earlier
let n = await t.environments.resolveEnvironment(i); if (!n) return e;
let s = n.executable?.sysPrefix || ...;         // "/usr" for system python
o.VIRTUAL_ENV = s;
o.PATH = `${bin}${delimiter}${c}`;              // /usr/bin prepended

How this was bisected: for each candidate version, I downloaded the linux-x64 .vsix from the marketplace gallery API, unpacked extension/extension.js, and checked for the guard.

| Version | Guard present |
|---|---|
| 2.1.145, 2.1.152-2.1.159, 2.1.165 | no (buggy) |
| 2.1.166 | yes (fixed) |
| 2.1.167-2.1.170, 2.1.223 | yes |

Consequence for anyone who hit this: the workaround of setting "claudeCode.usePythonEnvironment": false in .vscode/settings.json is no longer needed on 2.1.166+ and can be removed.

No action needed on this issue beyond closing it; filing it only so the fix is searchable, since the two original reports were closed as stale rather than fixed.

View original on GitHub ↗

This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗