Repository navigation
Commit 48f2559
committed
fix(cli): read PATH at its real length and probe Windows shim dirs (#221)
Two independent reasons `install` missed opencode on Windows 11:
1. find_in_path() copied PATH into a fixed 4 KB stack buffer through
cbm_safe_getenv(), and that helper REFUSES a value it cannot fit instead
of truncating it. On a machine whose PATH exceeds 4096 characters the
whole PATH was therefore skipped before a single directory was probed.
2. The fallback list had no Windows-shaped entries, and it probed only the
bare name, so npm's %APPDATA%\npm, mise's %LOCALAPPDATA%\mise\shims and
scoop's %USERPROFILE%\scoop\shims could never match a .cmd shim.
- Add cbm_env_dup() to platform.c: the allocating sibling of
cbm_safe_getenv, memory-core owned, wide-read on Windows so a non-ASCII
PATH is not mangled by the ANSI code page. cli.c no longer needs
<windows.h> in the middle of the file, nor any raw allocation.
- find_in_path() now exits once, so the PATH copy is freed on every path
instead of leaking on each success.
- Keep the existing pipx (~/.local/bin) and cargo (~/.cargo/bin) fallbacks,
built from the home_dir argument rather than cbm_get_home_dir(), and add
the npm/mise/scoop locations. PATHEXT is probed for every fallback
directory, not only for PATH entries.
- Bound the fallback loop by NUM_PATHS, not NUM_RETRIES.
- Hoist the PATHEXT list into one file-scope constant and add braces to
every one-line statement.
Regression guards in tests/repro/repro_issue221.c: a PATH longer than 4096
characters whose LAST entry holds the fixture, and the Windows fallback
shims driven through APPDATA / LOCALAPPDATA / the home_dir argument. Both
are red against the previous code and green with this change. The PATH
case is not Windows-specific: the same 4 KB cap hid entries on macOS and
Linux.
No raw allocator call site is added under src/, so the memory-core ratchet
is untouched; clang-format and the no-skips policy both pass locally.
Signed-off-by: Kris <[email protected]>1 parent 80eb92a commit 48f2559
4 files changed
Lines changed: 379 additions & 28 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| 25 | + | |
25 | 26 | | |
26 | 27 | | |
27 | 28 | | |
| |||
1076 | 1077 | | |
1077 | 1078 | | |
1078 | 1079 | | |
| 1080 | + | |
| 1081 | + | |
| 1082 | + | |
| 1083 | + | |
| 1084 | + | |
| 1085 | + | |
| 1086 | + | |
1079 | 1087 | | |
1080 | | - | |
| 1088 | + | |
| 1089 | + | |
| 1090 | + | |
| 1091 | + | |
| 1092 | + | |
| 1093 | + | |
| 1094 | + | |
| 1095 | + | |
| 1096 | + | |
1081 | 1097 | | |
1082 | | - | |
1083 | | - | |
| 1098 | + | |
| 1099 | + | |
1084 | 1100 | | |
1085 | 1101 | | |
1086 | | - | |
| 1102 | + | |
| 1103 | + | |
| 1104 | + | |
| 1105 | + | |
| 1106 | + | |
| 1107 | + | |
1087 | 1108 | | |
1088 | | - | |
| 1109 | + | |
1089 | 1110 | | |
1090 | | - | |
1091 | | - | |
1092 | | - | |
| 1111 | + | |
1093 | 1112 | | |
1094 | | - | |
1095 | | - | |
1096 | | - | |
1097 | | - | |
1098 | | - | |
1099 | | - | |
1100 | | - | |
1101 | | - | |
1102 | | - | |
1103 | | - | |
| 1113 | + | |
| 1114 | + | |
| 1115 | + | |
| 1116 | + | |
1104 | 1117 | | |
1105 | 1118 | | |
1106 | 1119 | | |
1107 | 1120 | | |
1108 | | - | |
| 1121 | + | |
| 1122 | + | |
| 1123 | + | |
1109 | 1124 | | |
1110 | 1125 | | |
1111 | 1126 | | |
| |||
1119 | 1134 | | |
1120 | 1135 | | |
1121 | 1136 | | |
| 1137 | + | |
| 1138 | + | |
| 1139 | + | |
| 1140 | + | |
| 1141 | + | |
1122 | 1142 | | |
1123 | 1143 | | |
1124 | | - | |
1125 | | - | |
1126 | | - | |
1127 | | - | |
1128 | | - | |
1129 | | - | |
| 1144 | + | |
| 1145 | + | |
| 1146 | + | |
| 1147 | + | |
| 1148 | + | |
| 1149 | + | |
| 1150 | + | |
| 1151 | + | |
| 1152 | + | |
| 1153 | + | |
| 1154 | + | |
| 1155 | + | |
| 1156 | + | |
| 1157 | + | |
| 1158 | + | |
| 1159 | + | |
| 1160 | + | |
| 1161 | + | |
| 1162 | + | |
| 1163 | + | |
| 1164 | + | |
| 1165 | + | |
1130 | 1166 | | |
1131 | | - | |
| 1167 | + | |
| 1168 | + | |
| 1169 | + | |
| 1170 | + | |
| 1171 | + | |
| 1172 | + | |
| 1173 | + | |
1132 | 1174 | | |
1133 | | - | |
1134 | | - | |
| 1175 | + | |
| 1176 | + | |
| 1177 | + | |
| 1178 | + | |
| 1179 | + | |
| 1180 | + | |
| 1181 | + | |
1135 | 1182 | | |
1136 | 1183 | | |
1137 | 1184 | | |
| 1185 | + | |
| 1186 | + | |
| 1187 | + | |
| 1188 | + | |
| 1189 | + | |
| 1190 | + | |
| 1191 | + | |
| 1192 | + | |
| 1193 | + | |
| 1194 | + | |
| 1195 | + | |
| 1196 | + | |
1138 | 1197 | | |
1139 | 1198 | | |
1140 | 1199 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
10 | 11 | | |
11 | 12 | | |
12 | 13 | | |
| |||
437 | 438 | | |
438 | 439 | | |
439 | 440 | | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
440 | 511 | | |
441 | 512 | | |
442 | 513 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
138 | 138 | | |
139 | 139 | | |
140 | 140 | | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
141 | 154 | | |
142 | 155 | | |
143 | 156 | | |
| |||
0 commit comments