-
-
Notifications
You must be signed in to change notification settings - Fork 69.6k
[Bug]: Windows 下执行 pnpm ui:build 失败,报错 'D:\Program' 不是内部或外部命令 #52282
Description
Bug type
Regression (worked before, now fails)
Summary
pnpm build
ui.js 脚本在调用 pnpm 时,使用了包含空格的路径(如 D:\Program Files...),但在 spawn 时没有用引号包裹,导致 Windows 命令解释器把空格前的部分(D:\Program)当作可执行文件,从而报错。
Steps to reproduce
克隆项目到本地(例如 D:\Openclaw\openclaw)
确保已安装 pnpm
执行 pnpm ui:build
出现错误:'D:\Program' 不是内部或外部命令,也不是可运行的程序或批处理文件。
PS D:\Openclaw\openclaw> pnpm ui:build
[email protected] ui:build D:\Openclaw\openclaw
node scripts/ui.js build
'D:\Program' 不是内部或外部命令,也不是可运行的程序
或批处理文件。
ELIFECYCLE Command failed with exit code 1.
Expected behavior
1
Actual behavior
1
OpenClaw version
latest
Operating system
win11
Install method
pnpm
Model
1
Provider / routing chain
1
Additional provider/model setup details
1
Logs, screenshots, and evidence
1Impact and severity
1
Additional information
在 run() 和 runSync() 函数中,对于 Windows 平台且需要 shell 执行的命令,如果路径包含空格,应手动用双引号包裹命令路径。例如:
js
function run(cmd, args) {
let actualCmd = cmd;
if (process.platform === 'win32' && shouldUseShellForCommand(cmd) && cmd.includes(' ')) {
actualCmd = "${cmd}";
}
// 其余不变
}
同样修改 runSync。
临时解决方案
用户可以自行修改 ui.js 添加上述引号逻辑,或将 pnpm 安装到不含空格的路径。