Skip to content

[Bug] Windows Git Bash: bash命令注入使用PowerShell $env:语法导致大量报错 #31904

@DawnCloud1213

Description

@DawnCloud1213

描述

Windows + Git Bash 环境(SHELL/BASH_VERSION/MSYSTEM 均设置),opencode.json 配为 "shell": "bash",但每次 bash 命令前仍注入 PowerShell 语法的环境变量,导致15行 command not found 报错:

/usr/bin/bash: line 1: :CI=true: command not found
/usr/bin/bash: line 1: :DEBIAN_FRONTEND=noninteractive: command not found
... (共约15行)

实际命令执行正常,但报错噪音严重。

环境

  • OS: Windows 11
  • Shell: Git Bash(SHELL=C:/Program Files/Git/usr/bin/bash, BASH_VERSION=5.2.37, MSYSTEM=MINGW64)
  • opencode.json: "shell": "bash"

根因

openconfig 在构造 bash 命令字符串时,系统级环境变量(CI/DEBIAN_FRONTEND/HOMEBREW_NO_AUTO_UPDATE/npm_config_yes/PIP_NO_INPUT 等)始终以 $env:VAR=value(PowerShell 语法)注入,未根据 "shell": "bash" 设置切换为 export VAR=value(bash 语法)。

建议

根据 opencode.json 的 shell 配置自适应环境变量注入语法:

  • bash → export VAR=val; cmd
  • powershell → $env:VAR='val'; cmd

AI 辅助撰写(OpenCode Sisyphus)

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions