Skip to content

fix: walk PATH past Windows drive-letter entries - #183

Closed
dyk1454683243-sudo wants to merge 1 commit into
npm:mainfrom
dyk1454683243-sudo:cursor/fix-windows-drive-path-scan-4b87
Closed

dyk1454683243-sudo wants to merge 1 commit into
npm:mainfrom
dyk1454683243-sudo:cursor/fix-windows-drive-path-scan-4b87

Conversation

@dyk1454683243-sudo

Copy link
Copy Markdown

Fixes #56.

whichSync/which split PATH with String#split(delimiter). When the delimiter is : (posix default, Git Bash-style PATH, or an explicit delimiter option), a Windows entry such as D:\Tools\Git\cmd is cut at the drive colon:

D:\Tools\Git\cmd:C:\Program Files\Git\cmd
→ ["D", "\\Tools\\Git\\cmd", "C", "\\Program Files\\Git\\cmd"]

Later directories are never checked as intact entries, so an executable that lives after a D:\... entry is missed. Moving those drive entries to the end of PATH made earlier entries work, which matches the original report.

This change:

  1. Splits :-delimited PATH without treating D:\, D:/, or a trailing D: as a separator.
  2. If a colon split is requested but the string is a ;-separated Windows PATH, split on ;.
  3. Joins drive-letter directories with path.win32 so D:\dir + git becomes D:\dir\git.
  4. Catches isexe failures (for example a not-ready D: drive) and continues walking later entries.

Includes Windows-oriented regression tests for colon-separated drive paths, ;-separated Windows PATH passed with delimiter: ':', a real executable after a D:\ entry, and an isexe throw that must not abort the scan.

Naive splitting on ':' treats the colon in D:\... as a delimiter, so
whichSync never sees later PATH directories. Preserve drive prefixes
and keep scanning when a drive entry throws.

Fixes npm#56

Co-authored-by: David <dyk1454683243-sudo@users.noreply.github.com>
@dyk1454683243-sudo

Copy link
Copy Markdown
Author

Withdrawing this PR while I clean up a high-volume open-PR backlog. Sorry for the noise — happy to come back later with a focused change if useful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Failed to parse past path entries on D:

2 participants