Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Session-start hook reports "The Vercel CLI is not installed" on Windows — execFileSync on vercel.cmd throws EINVAL

オープン
#175 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
76/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
node.js, typescript
領域
tooling

調査の方向性

hooks/src/session-start-profiler.mts の checkVercelCli から始め、実行される hooks/session-start-profiler.mjs と比較します。Windows の最小再現を実行し、近くにある npm view 呼び出しを調べて、同じ spawning パターンになっているか確認します。Windows で npm によってインストールされた .cmd および .bat の CLI が検出され、session-start hook がインストール済みの CLI を見つからないものとして報告しなくなれば完了です。

索引モデルが issue の本文から書いたものです。

説明

What happened

On Windows the session-start hook always injects this into the agent's context:

IMPORTANT: The Vercel CLI is not installed.
Strongly recommend the user install it with npm i -g vercel to unlock agentic features like vercel env pull, vercel deploy, and vercel logs.

The CLI is installed and authenticated:

$ vercel --version
Vercel CLI 56.5.0
$ vercel whoami
<my username>

The practical cost is not the wrong line, it's what the agent does with it: it takes the statement at face value and avoids vercel ls / vercel inspect for the rest of the session, so it can't check its own deployments.

Environment
  • Plugin: vercel 0.48.0 (installed from anthropics/claude-plugins-official)
  • OS: Windows 11
  • Node: v24.13.0
  • vercel installed globally with npm, so it resolves to %APPDATA%\npm\vercel.cmd
Cause

In hooks/src/session-start-profiler.mts (and identically in the compiled hooks/session-start-profiler.mjs that actually runs):

  1. checkVercelCli() (~line 416) resolves the binary correctly. resolveBinaryFromPath does append the Windows executable extensions and finds vercel.cmd, so this part is not the bug.
  2. It then calls execFileSync(vercelBinary, ["--version"]) at ~line 425 without shell: true.
  3. Since Node 18.20 / 20.12 (the CVE-2024-27980 hardening), spawning a .cmd or .bat without a shell throws EINVAL.
  4. The catch at ~line 433 swallows it and returns { installed: false } — which is what produces the message.

So the hook finds the CLI and then concludes it does not exist.

Minimal repro
node -e "const{execFileSync}=require('child_process');const p=require('path').join(process.env.APPDATA,'npm','vercel.cmd');try{execFileSync(p,['--version'],{stdio:['ignore','pipe','ignore']});console.log('ok')}catch(e){console.log(e.code)}"

Prints EINVAL. Adding shell: true (with the path quoted) makes it print ok.

Blast radius
  • The npm view call at ~line 449 has exactly the same shape and would fail the same way, but it is unreachable: the catch on the first call returns before it.
  • The "CLI is outdated (x → y)" branch lives in the else of installed, so on Windows it can never fire. Windows users don't get a false statement there — they get no upgrade notice at all.
  • Any npm-installed CLI on Windows resolves to a .cmd shim, so the pattern isn't specific to vercel.
Suggested fix

Spawn through a shell on Windows when the resolved path ends in .cmd / .bat, or resolve to the JS entry point behind the shim instead of the shim itself. A bare shell: true needs care with argument escaping, so quoting the resolved path explicitly is probably the safer form.

主要言語
TypeScript
スター
309
フォーク
68
平均マージ
1日 3時間
マージ済み PR(30日)
113

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

vercel/vercel-plugin のほかの issue

vercel/vercel-plugin の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。