Skip to content

fix: resolve file URL working directories on Windows - #191

Merged
43081j merged 2 commits into
tinylibs:mainfrom
anticipate218:fix/file-url-working-directory
Nov 24, 2026
Merged

43081j merged 2 commits into
tinylibs:mainfrom
anticipate218:fix/file-url-working-directory

Conversation

@anticipate218

Copy link
Copy Markdown
Contributor

On Windows, passing a file URL as nodeOptions.cwd can prevent relative shebang scripts and local node_modules/.bin commands from running, even when the equivalent string path works.

The environment builder converts the URL with windows: false, which prepends malformed paths such as C:\C:\project\node_modules.bin to PATH. Command resolution separately treats cwd.toString() as a filesystem path, so it searches relative to the literal file:///... value.

Convert file URLs to native paths in both places, while keeping the original cwd value in the options passed to Node. Use a platform-native URL in the existing environment fixture and add regressions for path/URL parity, relative shebang resolution, and async/sync execution from directories containing spaces, Unicode, #, and %.

This follows the URL support introduced in #166. Its existing subprocess check only searches for a path substring, which can also occur inside the malformed Windows path.

Validation on Windows, Node 26.13.1, npm 11.11.0:

  • Targeted tests: original implementation 7 failed / 6 passed; fixed implementation 13 passed. Four failures directly reproduce async/sync subprocess execution failures.
  • npm run format:check: passed.
  • npm run lint (TypeScript, ESLint, publint): passed.
  • npm test (build and full suite): build passed; 66 passed, 1 skipped, 5 failed. All five failures are existing tests that expect English cmd.exe error messages; this host emits Chinese diagnostics. The untouched upstream commit with the same Node version and an isolated copy of the same dependencies produces the same five failures, with 60 passed and 1 skipped. These tests were not skipped or changed to accommodate the host.

Native Linux/macOS, other Node versions, Bun, and English-language Windows were not run locally.

AI assistance: OpenAI Codex (GPT-6) assisted with investigation, implementation, regression tests, and this description.

anticipate218 and others added 2 commits November 18, 2026 07:21
The cwd never changed anyway so the assertion did nothing. The special
chars test doesn't need 2 parts.
@43081j
43081j force-pushed the fix/file-url-working-directory branch from 01488ab to d24546c Compare November 24, 2026 21:07
@43081j
43081j merged commit 6b8034c into tinylibs:main Nov 24, 2026
13 checks passed
@anticipate218

Copy link
Copy Markdown
Contributor Author

Thanks @43081j for tidying up the tests and merging! The simplified versions are much easier to follow.

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.

2 participants