Skip to content

Fix varlock run on Windows: correct cmd.exe command string quoting#618

Merged
philmillman merged 4 commits intomainfrom
copilot/fix-varlock-windows-scripts
Apr 15, 2026
Merged

Fix varlock run on Windows: correct cmd.exe command string quoting#618
philmillman merged 4 commits intomainfrom
copilot/fix-varlock-windows-scripts

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 15, 2026

varlock run fails on Windows when spawning .cmd-backed commands like tsx or pnpm. Two failure modes:

  • tsx watch src/index.tsThe system cannot find the path specified.
  • pnpm dlx auth generate"dlx" "auth" "generate" is not recognized as an internal or external command

Root cause

The needsShell block in exec.ts was individually quoting each token:

"C:\path\tsx.cmd" "watch" "src/index.ts"

cmd.exe /s /c strips only the first and last " from the entire string, leaving a stray " after the command name:

C:\path\tsx.cmd" "watch" "src/index.ts   ← invalid path, broken args

Changes

  • Fix quoting: wrap the entire inner command string in a single outer "..." pair, so cmd.exe's /s stripping consumes only those outer quotes and leaves the inner content intact:
    ""C:\path\tsx.cmd" "watch" "src/index.ts""
    → after /s strip →
    "C:\path\tsx.cmd" "watch" "src/index.ts"   ✓
    
  • Always quote all tokens: command path and every arg are now consistently wrapped in ", with embedded " escaped as "" (cmd.exe convention). Extracted escapeCmdExeArg() helper to avoid duplication.
  • PATHEXT fallback: when findCommand can't resolve a bare name to a .cmd/.bat path, needsShell now also fires so cmd.exe performs its own PATHEXT lookup (tsxtsx.cmd, pnpmpnpm.cmd) instead of failing with ENOENT.

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Apr 15, 2026

🦋 Changeset detected

Latest commit: 485322d

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 18 packages
Name Type
varlock Patch
@varlock/astro-integration Patch
@varlock/cloudflare-integration Patch
@varlock/expo-integration Patch
@varlock/nextjs-integration Patch
@varlock/vite-integration Patch
@varlock/1password-plugin Patch
@varlock/aws-secrets-plugin Patch
@varlock/azure-key-vault-plugin Patch
@varlock/bitwarden-plugin Patch
@varlock/dashlane-plugin Patch
@varlock/google-secret-manager-plugin Patch
@varlock/hashicorp-vault-plugin Patch
@varlock/infisical-plugin Patch
@varlock/keepass-plugin Patch
@varlock/pass-plugin Patch
@varlock/passbolt-plugin Patch
@varlock/proton-pass-plugin Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copilot AI linked an issue Apr 15, 2026 that may be closed by this pull request
Copilot AI and others added 3 commits April 15, 2026 14:36
Copilot AI changed the title [WIP] Fix varlock run command for Windows compatibility Fix varlock run on Windows: correct cmd.exe command string quoting Apr 15, 2026
Copilot AI requested a review from philmillman April 15, 2026 14:46
@philmillman philmillman marked this pull request as ready for review April 15, 2026 14:47
@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Apr 15, 2026

Open in StackBlitz

npm i https://pkg.pr.new/varlock@618

commit: 485322d

@philmillman
Copy link
Copy Markdown
Member

philmillman commented Apr 15, 2026

tested (and repro'd) on win11 pro with npm/npx and it works

@philmillman philmillman requested a review from theoephraim April 15, 2026 15:08
@philmillman philmillman merged commit 0db7d1d into main Apr 15, 2026
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG]: varlock run on windows

3 participants