Repository navigation
Commit 7b1e096
Pass the environment directory to uv package commands (#1742)
UV-backed package operations were constructed with
`environment.execInfo.run.executable`. For symlinked virtual
environments (e.g. Pipenv), that executable can resolve to a uv-managed
base interpreter, so `uv pip install --python <exe>` operated on the
externally managed base interpreter instead of the selected environment.
uv accepts an environment directory as its `--python` target, so the fix
is to hand UV commands `environment.environmentPath.fsPath` at the
pip/uv boundary. Ordinary pip commands still need the interpreter
executable.
### Changes
- **`src/managers/builtin/commands/factory.ts`**: when
`shouldUseUv(...)` selects uv, construct the UV command with a copy of
the options whose `pythonExecutable` is `environmentPath`. Pip commands
keep the original options.
- **`src/test/managers/builtin/commands.unit.test.ts`**: stub
`shouldUseUv` once in the existing setup and add regression coverage
that UV install/uninstall/list/direct-names all pass the environment
directory after `--python` and never the base interpreter, and that pip
still runs `runPython` with the original interpreter.
```ts
if (await shouldUseUv(options.log, environmentPath)) {
// uv accepts an environment directory as its `--python` target. A symlinked
// environment executable (for example Pipenv) can resolve to the externally
// managed base interpreter, so passing the environment directory preserves
// the environment boundary. Pip commands keep using the interpreter itself.
return { kind: 'uv', command: new UvCommand({ ...options, pythonExecutable: environmentPath }) };
}
return { kind: 'pip', command: new PipCommand(options) };
```
Fixing this centrally covers every factory-created UV operation without
touching each command class. Call sites were reviewed:
`UvVersionCommand` (`uv --version`) and `UvAvailableVersionsCommand`
(`uv tool run pip index versions …`) don't reference `pythonExecutable`
in their arguments, so they're unaffected.
This adapts the intent of #1673 to the command-class refactor merged
later in #1686.
---------
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: edvilme <5952839+edvilme@users.noreply.github.com>1 parent d0d52d1 commit 7b1e096
2 files changed
Lines changed: 95 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
15 | | - | |
16 | | - | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
17 | 22 | | |
18 | 23 | | |
19 | 24 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| 16 | + | |
16 | 17 | | |
17 | 18 | | |
18 | | - | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
19 | 23 | | |
20 | 24 | | |
21 | 25 | | |
| |||
28 | 32 | | |
29 | 33 | | |
30 | 34 | | |
| 35 | + | |
31 | 36 | | |
32 | 37 | | |
33 | 38 | | |
| |||
37 | 42 | | |
38 | 43 | | |
39 | 44 | | |
| 45 | + | |
40 | 46 | | |
41 | 47 | | |
42 | 48 | | |
| |||
259 | 265 | | |
260 | 266 | | |
261 | 267 | | |
262 | | - | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
263 | 272 | | |
264 | 273 | | |
265 | 274 | | |
| |||
282 | 291 | | |
283 | 292 | | |
284 | 293 | | |
285 | | - | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
286 | 298 | | |
287 | 299 | | |
288 | 300 | | |
| |||
319 | 331 | | |
320 | 332 | | |
321 | 333 | | |
322 | | - | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
323 | 338 | | |
324 | 339 | | |
325 | 340 | | |
| |||
349 | 364 | | |
350 | 365 | | |
351 | 366 | | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
352 | 435 | | |
0 commit comments