Commit 240b496
committed
fix(shim): make shim-map cache version-aware
The shim-map cache previously recorded shim → runtime only, with no
information about which installed runtime versions actually provide the
executable. Combined with the fact that `dtvem reshim` walks every
installed version and registers every executable it finds, this meant a
shim like `uv` (only installed against Python 3.9.9 via `pip install uv`)
would silently route to whatever Python version was active — even one
that didn't have `uv` at all.
This change:
- Bumps the shim-map schema to record `{runtime, versions[]}` per shim.
The loader tolerates the legacy flat-string schema by converting old
entries with empty Versions, signaling "version coverage unknown" so
callers skip the version check until the cache is regenerated.
- Updates `RehashWithCallback` to populate per-version coverage by
scanning each version's bin / Scripts / root directories. Drops the
blanket pre-population of the provider's declared core shims, which
previously asserted (incorrectly) that every installed version
provided every core shim — for example claiming a Windows embeddable
Python install provides `pip` even when its Scripts directory is
empty.
- Threads the install version through `CreateShimsForRuntime` so the
python / node / ruby providers register newly-installed shims with
the correct version.
- Adds a version-coverage check in `cmd/shim/main.go` and `cmd/which.go`:
when the active runtime version is not in the providing-versions list
recorded for a secondary shim, surface a richer error that names the
versions that DO provide it and how to switch.1 parent 0c49aaa commit 240b496
8 files changed
Lines changed: 470 additions & 273 deletions
File tree
- src
- cmd
- shim
- internal/shim
- runtimes
- node
- python
- ruby
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
62 | 76 | | |
63 | 77 | | |
64 | 78 | | |
| |||
228 | 242 | | |
229 | 243 | | |
230 | 244 | | |
231 | | - | |
232 | | - | |
233 | | - | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
234 | 248 | | |
235 | 249 | | |
236 | 250 | | |
237 | 251 | | |
238 | 252 | | |
239 | 253 | | |
240 | 254 | | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
241 | 288 | | |
242 | 289 | | |
243 | 290 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
| |||
70 | 71 | | |
71 | 72 | | |
72 | 73 | | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
73 | 88 | | |
74 | 89 | | |
75 | 90 | | |
| |||
102 | 117 | | |
103 | 118 | | |
104 | 119 | | |
105 | | - | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
106 | 124 | | |
107 | | - | |
108 | | - | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
109 | 128 | | |
110 | | - | |
111 | | - | |
112 | | - | |
113 | | - | |
| 129 | + | |
| 130 | + | |
114 | 131 | | |
115 | 132 | | |
116 | 133 | | |
| |||
120 | 137 | | |
121 | 138 | | |
122 | 139 | | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
123 | 169 | | |
124 | 170 | | |
125 | 171 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
6 | 7 | | |
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
11 | 12 | | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | | - | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
16 | 38 | | |
17 | 39 | | |
18 | 40 | | |
| |||
30 | 52 | | |
31 | 53 | | |
32 | 54 | | |
33 | | - | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
34 | 60 | | |
35 | 61 | | |
36 | 62 | | |
| |||
39 | 65 | | |
40 | 66 | | |
41 | 67 | | |
42 | | - | |
43 | | - | |
44 | | - | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
45 | 82 | | |
46 | 83 | | |
47 | | - | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
48 | 102 | | |
49 | 103 | | |
50 | 104 | | |
| |||
69 | 123 | | |
70 | 124 | | |
71 | 125 | | |
72 | | - | |
73 | | - | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
74 | 131 | | |
75 | 132 | | |
76 | 133 | | |
| |||
83 | 140 | | |
84 | 141 | | |
85 | 142 | | |
86 | | - | |
87 | | - | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
88 | 151 | | |
89 | 152 | | |
90 | 153 | | |
| |||
94 | 157 | | |
95 | 158 | | |
96 | 159 | | |
97 | | - | |
98 | | - | |
99 | | - | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
100 | 190 | | |
101 | 191 | | |
102 | | - | |
| 192 | + | |
103 | 193 | | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
104 | 197 | | |
105 | | - | |
106 | | - | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
107 | 206 | | |
108 | 207 | | |
109 | 208 | | |
| |||
0 commit comments