You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Fix Windows npx paths containing spaces (#163) - #164
On Windows, run npm and npx through the selected Node executable and CLI scripts instead of generated command wrappers. This prevents installation paths containing spaces from being split by cmd.exe.
This change is Windows-only and preserves Flock's bundled Node.js/npm behavior, project version selection, global npm packages, and certificate environment.
How I tested it
go test ./internal/node ./internal/cli — passed
GOOS=windows GOARCH=amd64 go test -c -o /tmp/flock-cli.test.exe ./internal/cli — passed
GOOS=windows GOARCH=amd64 go test -c -o /tmp/flock-node.test.exe ./internal/node — passed
git diff --check — passed
Checklist
I tested this change
I updated the docs in docs/, or no docs change is needed
This changes only the daemon or CLI, not the apps
This changes the apps, and I made and tested the change on every platform:
macOS
Windows
Linux
Summary by CodeRabbit
Bug Fixes
Improved Windows compatibility when running npm and npx, including installations in paths with spaces and updated npm installations.
npm and npx commands now run through Node.js on Windows, with the appropriate command-line scripts and environment settings.
When an npm or npx script is unavailable, the error identifies the Node.js version and tool.
Thanks for the PR, @elhoceyne! Flock takes pull requests only for issues a maintainer has approved, so this one is closed. Edit this pull request's description to reference an approved issue, then save it to reopen automatically. See CONTRIBUTING.md.
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
The Node fixture lacks bundled npm metadata and breaks Windows CI, while Windows regression coverage is still missing for npm and npx execution from paths containing spaces.
Fixes #163 by running npm and npx through Flock’s selected Node executable on Windows, avoiding command-wrapper failures when installation paths contain spaces.
Changes:
Passes npm/npx CLI scripts directly to node.exe, retaining existing arguments and environment settings.
Adds npx script lookup that prefers the major version’s updated npm package over bundled npm.
Adds a test for bundled and updated npx selection.
File
Description
internal/node/npm.go
Adds npx CLI script resolution.
internal/node/npm_test.go
Tests bundled and updated npx selection.
internal/cli/exec.go
Routes Windows npm/npx execution through the selected node.exe.
Reviewing files that changed from the base of the PR and between 6ef1567 and da0b748.
You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.
Use the checkbox below for a quick retry:
Trigger review
No actionable comments were generated in the recent review.
Walkthrough
The change adds lookup for the npx CLI script in global and version-local npm packages. On Windows, resolveTool runs npm and npx through node.exe instead of invoking .cmd wrappers.
Npx checks the major-specific global prefix and then the Node version directory for npx-cli.js. The test checks bundled and updated global npm installations.
Windows npm and npx execution internal/cli/exec.go, internal/cli/exec_test.go, internal/cli/exec_windows_test.go
On Windows, resolveTool runs npm and npx CLI scripts through node.exe and returns an error when a script is unavailable. The tests cover platform-specific fixtures, paths with spaces, environment entries, and updated npm resolution.
The change runs npm and npx on Windows through node.exe and their CLI scripts, so install paths containing spaces no longer break npx. The review found no concrete defect, and the change is Windows-only with non-Windows behavior unchanged. It looks ready to merge.
Security architecture risk: Low · up to bd21f
Launching npm and npx directly through Node fixes the wrapper’s handling of paths with spaces without adding a new privilege or network entry point. The remaining risk is local: an incomplete shared npm installation can block the bundled copy for Windows projects using the same Node major.
Retained concerns
Low · reliability · inferred: An incomplete major-global npm package can mask a usable bundled package. The new lookup selects the global package from version metadata alone, so if its requested CLI script is missing, Windows invocations for projects resolving to that major can fail without trying the bundled script. The base resolver selected the bundled wrapper when the global wrapper was absent.
Security review details
Security Blast Radius
inferred — The changed launch decision applies to local Windows npm and npx invocations. Projects under the same installation root that resolve to the same Node major can select the same global npm package; the lookup does not select a package from the project directory.
Trust Boundaries and Controls
observed — The CLI derives the executable and script paths before passing user arguments to the existing child-process launcher. The initial Node executable is selected from the installation rather than searched for on PATH, and the launcher requests no different credentials.
Hardening Proposals
proposed — Consider checking that the requested CLI script exists before preferring the major-global package, so an incomplete global install does not hide an available bundled script. Cover this fallback for both npm and npx.
Pre-merge checks: 4
Check name
Status
Explanation
Title check
The title names the main change: fixing Windows npx paths that contain spaces, which matches the Windows-only change to run npm and npx through node.exe and the CLI scripts. It also references issue #…
Description check
The description fills in the template's core parts: it links the issue with 'Fixes #163', explains the what and why, lists the test commands run and their results, and completes the checklist for the …
Linked Issues check
Issue #163 asks that npx run on Windows when Flock is installed under a path with spaces. At head, internal/cli/exec.go resolveTool handles the node, npm, and npx tools. On Windows, for npm and npx (n…
Out of Scope Changes check
All changed areas connect to the issue #163 fix. internal/cli/exec.go changes the Windows npm and npx selection. internal/node/npm.go adds the Npx lookup that this selection requires. internal/cli/exe…
Full details: Title check
Explanation
The title names the main change: fixing Windows npx paths that contain spaces, which matches the Windows-only change to run npm and npx through node.exe and the CLI scripts. It also references issue #163, which the linked objectives describe.
Full details: Description check
Explanation
The description fills in the template's core parts: it links the issue with 'Fixes #163', explains the what and why, lists the test commands run and their results, and completes the checklist for the Windows-only change. The required 'Fixes #' line is present with a value. The macOS and Linux app-platform boxes are unchecked, which is correct because the change touches only the CLI and is Windows-only.
Full details: Linked Issues check
Explanation
Issue #163 asks that npx run on Windows when Flock is installed under a path with spaces. At head, internal/cli/exec.go resolveTool handles the node, npm, and npx tools. On Windows, for npm and npx (not node), it selects the CLI script with node.Npm or the new node.Npx, sets path to binDir/node.exe, and returns argv {node.exe, cli, args...}. This avoids the generated npx.cmd and npm.cmd wrappers that split the path at the space. internal/node/npm.go adds Npx(root, version), which finds npx-cli.js in the same lookup order as Npm (major global prefix first, then the bundled version directory). It returns an empty string when no npm package exists, and resolveTool reports that as an error. The change is limited to Windows. Non-Windows tools keep the existing lookup, and Windows node still runs node.exe. Tests cover the change: internal/cli/exec_windows_test.go adds TestResolveToolRunsWindowsNpmThroughNodeWithSpaces and TestResolveToolRunsWindowsNpxThroughUpdatedNodeWithSpaces, and internal/node/npm_test.go adds TestNpxUsesTheUpdatedOne. The PR reports that the Windows test binaries compile. It does not report running them on Windows. The issue's reproduction involves the bin\npx.exe shim, which still exists. That shim now routes through flk exec, which runs node.exe directly, so the reported failure path is no longer used by exec. This is inferred from code at head, not from a Windows run.
Full details: Out of Scope Changes check
Explanation
All changed areas connect to the issue #163 fix. internal/cli/exec.go changes the Windows npm and npx selection. internal/node/npm.go adds the Npx lookup that this selection requires. internal/cli/exec_test.go changes the Node/Vite TLS fixture to create node.exe and an npm package layout for Windows and other platforms. This supports the existing TLS test after the resolveTool change. The new Windows and npm tests verify the new behavior. The PR description states the change preserves bundled Node/npm behavior, version selection, global packages, and the certificate environment. In the code at head, NpmEnv and the NODE_EXTRA_CA_CERTS setting remain applied before the platform branch. No unrelated feature or refactor was found in the reviewed areas.
Finishing Touches
Generate unit tests (beta)
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Reviewing files that changed from the base of the PR and between 1cb007d and bd21f95.
Files selected for processing: 5
internal/cli/exec.go
internal/cli/exec_test.go
internal/cli/exec_windows_test.go
internal/node/npm.go
internal/node/npm_test.go
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
I have rebased the PR onto the latest main and addressed all review feedback and Copilot findings:
Windows Node Fixture: Added bundled npm metadata to the Windows Node fixture in internal/cli/exec_test.go.
Regression Tests: Added dedicated regression tests for Windows npm and npx path resolution with spaces in internal/cli/exec_windows_test.go (TestResolveToolRunsWindowsNpmThroughNodeWithSpaces and TestResolveToolRunsWindowsNpxThroughUpdatedNodeWithSpaces).
Core Test Suite: All Go tests, vet checks, and kit tests pass 100% on Windows, macOS, and Linux:
Go test (Windows): PASS
Go vet (Windows): PASS
Go test (macOS & Linux): PASS
windows / Windows App (Kit Tests): PASS (187/187)
Note on Windows Tray Build in CI
When testing the full matrix on the windows-2025 runner, Windows App (Tray Build) encountered error CsWinRT1032 in windows/Flock.Tray/ (due to recent .NET SDK / CsWinRT analyzer rules flagging collection expressions [...] targeting IReadOnlyList<string> under TreatWarningsAsErrors).
This is upstream in the C# desktop app and independent of the Go CLI changes in this PR. I kept this PR strictly scoped to Issue #163 and the Go CLI, but I am happy to open a separate PR to resolve the CsWinRT warnings if helpful.
Whenever you have a moment, could you please approve the workflow run on upstream? Thanks!
The reason will be displayed to describe this comment to others. Learn more.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #163
What and why
On Windows, run npm and npx through the selected Node executable and CLI scripts instead of generated command wrappers. This prevents installation paths containing spaces from being split by
cmd.exe.This change is Windows-only and preserves Flock's bundled Node.js/npm behavior, project version selection, global npm packages, and certificate environment.
How I tested it
go test ./internal/node ./internal/cli— passedGOOS=windows GOARCH=amd64 go test -c -o /tmp/flock-cli.test.exe ./internal/cli— passedGOOS=windows GOARCH=amd64 go test -c -o /tmp/flock-node.test.exe ./internal/node— passedgit diff --check— passedChecklist
docs/, or no docs change is neededSummary by CodeRabbit