网站上创建claude对话,Process exited unexpectedly: Claude Code executable not found at C:\Users\a6318\AppData\Roaming\npm\node_modules\@anthropic-ai\claude-code\bin\claude. Is options.pathToClaudeCodeExecutable set?
What version of HAPI is running?
最新版本
What platform is your computer?
windows
What issue are you seeing?
显示找的是Process exited unexpectedly: Claude Code executable not found at C:\Users\a6318\AppData\Roaming\npm\node_modules@anthropic-ai\claude-code\bin\claude. Is options.pathToClaudeCodeExecutable set? 并且我已经设置了环境变量HAPI_CLAUDE_PATH = "C:\Users\a6318\AppData\Roaming\npm\node_modules@anthropic-ai\claude-code\bin\claude.exe",通过hapi cli可以启动claude,网站上就不可以
What steps can reproduce the bug?
查看网站端创建会话找CLAUDE的调用方法
What is the expected behavior?
修复网站端的BUG
Additional information
No response
从当前代码看,网站端创建 Claude 会话并不是在浏览器里直接找 claude.exe,而是走:Web → Hub → 机器上的 runner → runner 再启动 hapi claude。所以这个报错来自 runner 启动出来的本机 HAPI/Claude 子进程。HAPI_CLAUDE_PATH 必须对正在运行的 runner 进程可见;如果是在 runner 启动后才设置环境变量,需要重启 runner。
建议先在同一个 Windows 终端里执行:
$env:HAPI_CLAUDE_PATH = 'C:\Users\a6318\AppData\Roaming\npm\node_modules\@anthropic-ai\claude-code\bin\claude.exe'
hapi runner start
注意不要把引号写进环境变量值本身。hapi runner start 会停止已有 runner 并重新启动,所以新环境变量才会生效。然后再从网站创建 Claude 会话。
Relevant code:
web/src/api/client.ts:463- 网站创建会话调用/api/machines/:id/spawn。hub/src/web/routes/machines.ts:25- Hub 的 spawn 接口接收网站请求。hub/src/sync/rpcGateway.ts:107- Hub 通过spawn-happy-sessionRPC 转发给指定机器。cli/src/api/apiMachine.ts:251- 机器端 runner 注册并处理spawn-happy-session。cli/src/runner/run.ts:381- runner 构造要启动的 HAPI 命令参数。cli/src/runner/run.ts:402- runner 启动子进程,并继承process.env。cli/src/runner/run.ts:903- Claude agent 会被构造成hapi claude --hapi-starting-mode remote --started-by runner。cli/src/claude/claudeRemote.ts:139- remote Claude 会话把getDefaultClaudeCodePath()传给 Claude SDK。cli/src/claude/sdk/utils.ts:149-HAPI_CLAUDE_PATH是 Claude 可执行文件路径的显式覆盖。cli/src/claude/sdk/query.ts:371- 报错文本来自这里的可执行文件存在性检查。cli/src/commands/runner.ts:211- runner 帮助文本说明重新运行hapi runner start会让新环境变量生效。
Need more info:
- 重启 runner 后是否仍然报同一个路径?
hapi runner logs最新日志里[Claude SDK]相关几行是什么?- 你设置的是用户环境变量、系统环境变量,还是只在某个终端里设置的
$env:HAPI_CLAUDE_PATH?
HAPI Bot