Skip to content

Windows: session-start-profiler falsely reports "Vercel CLI is not installed" (runs the bash launcher without a shell) #105

Open

Description

@seanl-dev1

Summary

On Windows, the SessionStart hook (hooks/session-start-profiler.mjs → checkVercelCli()) reports "The Vercel CLI is not installed" on every session start, even when the CLI is installed globally and on PATH (vercel --version → 52.0.0).

Environment

  • OS: Windows 11
  • Node: v24.14.1, npm 11.11.0
  • Vercel CLI: 52.0.0, global install at C:\Users\<user>\AppData\Roaming\npm\ (contains vercel, vercel.cmd, vercel.ps1)
  • Plugin: [email protected] (the bug is identical in 0.40.0)

Root cause

resolveBinaryFromPath("vercel") builds candidate names as ["", ".EXE", ".CMD", ...] — bare name first (getBinaryPathCandidates, the ["", ...WINDOWS_EXECUTABLE_EXTENSIONS] order). So on Windows it returns the extensionless …\npm\vercel (the Unix shell launcher npm also drops in the bin dir) before vercel.cmd. checkVercelCli() then runs it with no shell:

execFileSync(vercelBinary, VERCEL_VERSION_ARGS, { /* ... */ stdio: SPAWN_STDIO })

execFileSync without a shell cannot execute a shell script (nor a .cmd) on Windows → throws ENOENT → the catch returns { installed: false } → the hook emits the false "not installed" message.

Minimal reproduction

const { execFileSync } = require("node:child_process");
const bin = process.env.APPDATA + "\\npm\\vercel"; // the extensionless launcher resolveBinaryFromPath returns
execFileSync(bin, ["--version"]);                  // THROWS ENOENT
execFileSync(bin, ["--version"], { shell: true }); // OK -> 52.0.0

Proposed fix

Run the version check (and ideally the npm view check) through a shell on Windows:

const raw = execFileSync(vercelBinary, VERCEL_VERSION_ARGS, {
  timeout: EXEC_SYNC_TIMEOUT_MS,
  encoding: "utf-8",
  stdio: SPAWN_STDIO,
  shell: process.platform === "win32",
}).trim();

(Heads-up: shell: true + an args array triggers Node's DEP0190. It's harmless here since the args are a fixed --version, but if you'd rather avoid the warning you can build a single command string, or alternatively prefer the PATHEXT-extension candidates over the bare name on Windows and shell-out for .cmd.)

Happy to open a PR if useful.

Activity

  1. shivakrishnakokkula commented on Jul 29, 2026

    @shivakrishnakokkula

    Confirming this still reproduces, and adding a second symptom from the same code path.

    Still present in 0.45.1 (this issue reports 0.40.0 / 0.43.0), Node v24.14.0, Windows 11, Vercel CLI 57.0.0 installed globally at C:\Users\<user>\AppData\Roaming\npm\.

    Running resolveBinaryFromPath + checkVercelCli verbatim against the real process PATH:

    platform          : win32
    node              : v24.14.0
    RESOLVED TO       : C:\Users\<user>\AppData\Roaming\npm\vercel
    execFileSync FAILED after 2 ms
      code   : ENOENT
      message: spawnSync C:\Users\<user>\AppData\Roaming\npm\vercel ENOENT
    => would report NOT INSTALLED
    
    CONTROL: "...\npm\vercel.cmd" with shell:true => "57.0.0"
    

    Exactly the diagnosis above: the bare name is tried before the PATHEXT variants, and accessSync(path, X_OK) on Windows doesn't distinguish executables, so the extensionless Unix launcher wins over vercel.cmd.

    New: the same path also breaks npm detection, which I don't think has been reported.

    npm     -> C:\Program Files\nodejs\npm | spawn FAILED (ENOENT) -> reported as NOT INSTALLED
    vercel  -> C:\Users\<user>\AppData\Roaming\npm\vercel | spawn FAILED (ENOENT) -> reported as NOT INSTALLED
    

    checkVercelCli() calls resolveBinaryFromPath("npm") for the npm view vercel version update check, and npm has the same extensionless-launcher-plus-.cmd layout. So on Windows that branch can never succeed either — the CLI update check silently never runs, independently of the "not installed" message. Anyone who fixes only the vercel call will still leave the update check dead.

    That makes the candidate-ordering fix (prefer PATHEXT extensions over the bare name on win32) preferable to shelling out only in checkVercelCli, since it repairs both call sites at once.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions