Skip to content

[Windows] webSearchTool 配置自定义脚本时 spawn 失败 (Node.js v24 已移除 .bat 自动路由) #190

Description

@user-lzy

在 Windows 上配置 webSearchTool 指向 .bat 文件时,因 Node.js v20+ 已移除 child_process.spawn 对 .bat/.cmd 文件的自动
cmd.exe /c 路由,抛出 spawn EINVAL。

稳定复现步骤

  1. 创建任意 .bat 文件,例如:
    [bat]
    @echo off
    echo {"results":[{"title":"test"}]}
  2. 配置 settings.json:
    [json]
    "webSearchTool": "C:/path/to/script.bat"
  3. 在对话中调用 WebSearch 工具
  4. 结果:spawn EINVAL

Node.js 验证

[javascript]
const { spawn } = require('child_process');
spawn('C:/path/to/script.bat', ['query'], {
stdio: ['ignore', 'pipe', 'pipe']
});
// → Error: spawn EINVAL (Node v24.15.0, Windows)

建议修复

在 src/tools/web-search-handler.ts 的 runWebSearchScript 中根据平台添加 shell: true:

[diff]
const child = spawn(scriptPath, [query], {
cwd: context.projectRoot,

  • shell: process.platform === "win32",
    env: { ...process.env, ...configuredEnv },
    stdio: ["ignore", "pipe", "pipe"],
    });

Activity

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