Commit 688c47e
authored
fix(shims): Preserve system PATH case on Windows in goenv exec (#561)
* fix(shims): Preserve system PATH case on Windows in goenv exec (#557)
Windows environment variables are case-insensitive but os.Environ() preserves
the original casing (e.g., Path, PATH, path). Previously, setEnvVar() and
prependToPath() used case-sensitive string matching, causing duplicate
environment variables when the casing didn't match exactly.
This caused PATH to be overwritten instead of prepended, breaking CGO builds
when gcc was in the system PATH but not found after goenv exec.
Changes:
- Added findEnvVar() helper that uses case-insensitive matching on Windows
- Updated setEnvVar() to use findEnvVar and preserve original casing
- Updated prependToPath() to use findEnvVar and preserve original casing
- Added comprehensive unit tests including regression test for issue #557
Fixes #557
* [AB#557] docs: Add optional cross-platform testing with nektos/act
Added instructions for developers who want to run cross-platform CI tests
locally using nektos/act before pushing to GitHub.
Also fixed PATH separator detection in prependToPath() to handle cross-
platform test scenarios where Unix-style paths (with :) are tested on
Windows runners (which default to ; separator).
Changes:
- Added nektos/act installation and usage guide to agent instructions
- Updated when-to-use guidance to cover all OS-specific code, not just shims
- Fixed prependToPath() to detect separator from existing PATH value
- Updated repo memory with cross-platform testing guidance
This is optional - CI always runs full cross-platform tests automatically.
* [AB#557] style: Apply automated formatting
- Format markdown sections with proper spacing
- Align test struct fields
- Clean up whitespace in exec.go
* fix(test): Use count check for colon separator detection
Fixed Windows test failures where drive letter colons (C:) were being
incorrectly detected as path separators.
Changed separator detection from:
- strings.Contains(currentPath, ":")
to:
- strings.Count(currentPath, ":") > 1
This distinguishes between:
- Drive letters: C:\Windows\System32 (one colon)
- Path separators: /usr/bin:/usr/local/bin (multiple colons)
Fixes test failures:
- TestPrependToPath/prepend_to_existing_path_-_Windows_(lowercase)
- TestPrependToPath/prepend_to_existing_PaTh_-_Windows_(mixed_case)
* fix(shims): improve separator detection to handle single-colon Unix paths
Previous logic failed when Unix paths had exactly 1 colon (e.g., /usr/bin:/bin)
because the check was 'count > 1'. This caused Windows CI tests to incorrectly
use semicolon as separator when testing Unix-style paths.
New logic:
- Checks for semicolons first (Windows-style)
- Counts colons but excludes drive letter colons (position 1)
- Any remaining colons indicate Unix-style separator
- Falls back to OS default separator if neither detected
Fixes Windows CI test failure for 'prepend to existing PATH - Unix' case.
Issue #5571 parent ea61d60 commit 688c47e
4 files changed
Lines changed: 400 additions & 16 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
315 | 315 | | |
316 | 316 | | |
317 | 317 | | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
318 | 365 | | |
319 | 366 | | |
320 | 367 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
220 | 220 | | |
221 | 221 | | |
222 | 222 | | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
223 | 266 | | |
224 | 267 | | |
225 | 268 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
374 | 374 | | |
375 | 375 | | |
376 | 376 | | |
377 | | - | |
378 | | - | |
379 | | - | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
380 | 381 | | |
381 | | - | |
382 | | - | |
383 | | - | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
384 | 399 | | |
385 | 400 | | |
386 | | - | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
387 | 415 | | |
388 | 416 | | |
389 | 417 | | |
| |||
392 | 420 | | |
393 | 421 | | |
394 | 422 | | |
395 | | - | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
396 | 427 | | |
397 | | - | |
398 | | - | |
399 | | - | |
400 | | - | |
401 | | - | |
402 | | - | |
403 | | - | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
404 | 450 | | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
405 | 456 | | |
406 | 457 | | |
407 | | - | |
| 458 | + | |
408 | 459 | | |
0 commit comments