Git Bash 中无法启动 Claude Code ?

最近需要在 git bash 中跑 Claude Code 。

git bash 是随 git for windows 套件安装的,很久没更新了,结果启动 Claude Code 报错:

Warning: no stdin data received in 3s, proceeding without it. If piping from a slow command, redirect stdin explicitly: < /dev/null to skip, or wait longer.

Error: Input must be provided either through stdin or as a prompt argument when using --print

问题的原因是 Claude Code 需要一个完整的交互式终端环境,启动时会尝试从标准输入(stdin)读取数据,但 Git Bash 默认使用旧的终端模拟(mintty + 传统的 PTY 方式),而不是 Windows 的 ConPTY(Console Pseudo Terminal)。

简单说,Claude Code 需要一个完备的现代化的终端环境,但 git bash 默认不是。

解决方法也简单。

1、临时方案

在终端中输入

复制代码
export MSYS=enable_pcon

即可。

但这样的话每次重启 git bash ,都要输入命令,很麻烦。

2、自动化方案

在 ~/.bashrc 或 ~/.bash_profile 末尾加上:

复制代码
export MSYS=enable_pcon

然后重启 Git Bash。

3、最佳方案

去git 官网下载最新git for widows 套件:

https://git-scm.com/install/windows

覆盖安装即可。

如果不考虑旧版本兼容问题,直接覆盖安装。

另外,安装时强烈建议勾选上

Add a Git Bash Profile to Windows Treminal

这样 Windows 终端中就可以启动 Git Bash了。

搭上 Windows 终端,不但显示效果上了个台阶,操作便捷性也极大提升。

首先是所有终端都可以结合到一个窗口中,通过标签页切换;复制/粘贴再也不用 Ctrl Ins/Shift Ins了,好处多多。

相关推荐
触底反弹8 小时前
Vibe Coding 不写 Git,等于悬崖边飙车
人工智能·git·面试
星栈独行8 小时前
翻完 Pi 源码:它和 Codex、Claude Code 有何不同
开发语言·javascript·人工智能·程序人生
qq_448011169 小时前
C语言中的变量和函数的定义与声明
android·c语言·开发语言
泡沫冰@9 小时前
基于Git、Jenkins、Podman、ECS的CI/CD实践
git·jenkins·podman
zfoo-framework10 小时前
git拦截大于5M文件
git
孫治AllenSun10 小时前
【DataX】生产环境搭建DataX集群案例
java·开发语言·jvm
c2385611 小时前
把 C++ 内存分配拆透:new 与 malloc 的三层血缘
开发语言·c++·算法
moonsims12 小时前
星闪在跨域无人化系统作用
开发语言·php
Iruoyaoxh13 小时前
栈和队列~
java·开发语言
Hrain-AI13 小时前
2026 企业 AI 编程智能体实战:Codex 与 Claude Code
开发语言·人工智能·kotlin