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 小时前
Spring定时任务开发指南(动态实现)
java·开发语言·后端·python·spring·wpf
不绝1918 小时前
AB包相关知识
开发语言·lua
lly2024068 小时前
WebPages 发布
开发语言
xuhaoyu_cpp_java8 小时前
Git学习(六)
git·学习
冉卓电子8 小时前
MPC5604B/C MC_RGM 复位模块全解
c语言·开发语言·单片机·嵌入式硬件
Chris _data8 小时前
C# 与 PLC Modbus RTU 通信实践:从单例到线程安全的连接监控
开发语言·安全·c#
不负岁月无痕8 小时前
STL-- C++ vector类 模拟实现
开发语言·c++
晚烛8 小时前
CANN 分布式通信与 HCCL:多 NPU 协作的底层机制
开发语言·人工智能·分布式·python·深度学习
装不满的克莱因瓶8 小时前
新版AI开发框架SpringAIAlibaba vs AgentScope 选型指南
java·开发语言·人工智能·ai·agent·alibaba·springai