Repository navigation
Commit 9d084c2
fix(isolation): detect the runtime of Windows launchers with an .exe/.cmd suffix (#1778)
## Problem
`IsolationManager.DetectRuntimeType` switches on
`filepath.Base(command)` exactly. On Windows the launchers carry an
executable suffix: `uvx.exe`, `npx.cmd`, `npm.cmd`, `yarn.cmd`,
`pip.exe`, `go.exe`. Configs often name them that way, either by full
path or because `npx.cmd` is what resolves. None of those match a case,
so they fall to the `binary` default. `python.exe` and `node.exe` only
work through the substring fallback.
With Docker isolation enabled, `binary` selects the generic image, and
`TransformCommandForContainer` passes the original command through. The
container is asked to run `npx.cmd` (or `uvx.exe`) inside a Linux image
where it doesn't exist, so the server never starts.
## Fix
Lowercase the base name and strip a `.exe`, `.cmd` or `.bat` suffix
before the switch, so `npx.cmd` maps to `npx`, `uvx.exe` to `uvx`, and
so on. Then the right image and in-container command are used.
Unsuffixed names are unchanged.
## Test
`TestDetectRuntimeType_WindowsExecutableSuffix` covers `uvx.exe`,
`npx.cmd`, `NPX.CMD`, `npm.cmd`, `yarn.cmd`, `pip.exe` and `go.exe`,
plus `uvx` and an unknown `my-tool`. On main all seven suffixed names
return `binary`; with this change they map to their runtime. `go test
-count=1 ./internal/upstream/core/` passes.
Made with [Cursor](https://cursor.com)
---------
Co-authored-by: Algis Dumbris <a.dumbris@gmail.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>1 parent e138559 commit 9d084c2
4 files changed
Lines changed: 72 additions & 7 deletions
File tree
- internal
- diagnostics
- upstream/core
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
68 | 68 | | |
69 | 69 | | |
70 | 70 | | |
71 | | - | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
72 | 79 | | |
73 | 80 | | |
74 | 81 | | |
| |||
101 | 108 | | |
102 | 109 | | |
103 | 110 | | |
104 | | - | |
105 | | - | |
| 111 | + | |
106 | 112 | | |
107 | 113 | | |
108 | | - | |
| 114 | + | |
109 | 115 | | |
110 | 116 | | |
111 | | - | |
| 117 | + | |
112 | 118 | | |
113 | 119 | | |
114 | 120 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
72 | 72 | | |
73 | 73 | | |
74 | 74 | | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
220 | 220 | | |
221 | 221 | | |
222 | 222 | | |
223 | | - | |
224 | | - | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
225 | 230 | | |
226 | 231 | | |
227 | 232 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
0 commit comments