tracer icon indicating copy to clipboard operation
tracer copied to clipboard

Fix trace command cwd handling on Windows

Open mysubb01 opened this issue 6 months ago • 4 comments

Summary

  • remove the inline cd ...; wrapper from the trace command
  • run the configured trace command with spawn using cwd instead
  • add shell quoting helpers and tests for Windows/POSIX trace directory substitution

Why

This addresses #48. On Windows, cd without /d cannot switch drives, so a project on P: launched from a storage path on C: fails before tsc --generateTrace runs. Passing the project path through spawn({ cwd }) avoids embedding a drive-changing cd in the shell command.

Verification

  • pnpm lint
  • pnpm typecheck
  • pnpm exec vitest run
  • pnpm build

mysubb01 avatar May 22 '26 22:05 mysubb01

Maintainer ping: PR #77 looks like the right fix for issue #48 (Windows cross-drive failure) by using instead of an inline wrapper.

FYI: currently reports no checks on the branch and the PR shows . If that’s just because CI isn’t running on forks / needs manual approval, could you trigger CI (or confirm the expected check suite) and merge if it’s green?

MyTH-zyxeon avatar Jun 01 '26 03:06 MyTH-zyxeon

Correction (shell ate backticks in my prior comment):

  • Issue: Windows cross-drive cd fails when the command is wrapped as (cd <path>; <cmd>).
  • Fix idea in #77: use spawn(..., { cwd: <path> }) (or equivalent) so we don't rely on shell cd.

Also: gh pr checks currently reports "no checks" on the branch and the PR shows mergeStateStatus=UNSTABLE, so it may need a maintainer-triggered CI run / fork approval gate.

MyTH-zyxeon avatar Jun 01 '26 03:06 MyTH-zyxeon

Nice fix — removing the inline (cd ...; ...) wrapper and relying on spawn({ cwd }) is the right way to avoid Windows cross-drive cd semantics.

One small thought: shell: process.env.SHELL || true can reintroduce quoting mismatches on Windows if SHELL is set to Git-Bash (POSIX quoting) while quoteShellArg(..., platform) stays win32 (double-quote) semantics. If you don’t need a user-selected shell here, shell: true (platform default) might be safer/deterministic.

Otherwise createTraceCommand + the new tests look solid.

MyTH-zyxeon avatar Jun 01 '26 19:06 MyTH-zyxeon

One extra merge-safety thought: the quoting strategy and shell selection should stay aligned.

Right now createTraceCommand(...) quotes based on process.platform, but the spawn call uses shell: process.env.SHELL || true. On Windows setups launched from Git Bash / MSYS, that can mean win32-style quoting is handed to a POSIX shell.

Low-risk options:

  • use shell: true so the platform-default shell matches the platform-specific quoting logic, or
  • make the quoting strategy depend on the actual shell being used, not just process.platform.

If you keep the current shape, one focused regression test around a Windows path with spaces while SHELL is set to a POSIX shell would help confirm the command still executes as intended.

MyTH-zyxeon avatar Jun 02 '26 07:06 MyTH-zyxeon