0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【Cursor】Git Bashでuname: command not foundが出た時の解決メモ

Posted at

CursorでGit Bashが動かない問題の解決メモ

はじめに

CursorでGit Bash使おうとしたらbash: uname: command not foundとか出てきて困った。
環境変数とかbashとか正直よくわかってないんだけど、なんとか解決できたので備忘録。

同じ問題で困ってる人がいたら参考にしてください🙏

何が起きたか

bash: uname: command not found
$ which cat
bash: which: command not found
  • 基本的なコマンドが全部使えない
  • プロンプトがMSYSになってる(普通はMINGW64らしい)
  • でもスタートメニューから開いたGit Bashは普通に動く

vscodeでは問題なく使えていたのにcursorに移行したらおかしくなった...

原因(多分)

調べたらこういうことらしい:

1. bash.exeのパスが違った

Git for Windowsって2つbash.exeがあるらしい:

  • C:\Program Files\Git\bin\bash.exe (47KB) - これじゃダメ
  • C:\Program Files\Git\usr\bin\bash.exe (2.5MB) - こっちが正解

2. Cursorのシェル統合がジャマしてた

Cursorが起動時に独自のスクリプト読み込んで、それが環境変数とか壊してたっぽい。

解決方法

1. Cursorの設定変更

Ctrl + Shift + PPreferences: Open User Settings (JSON) で設定開いて:

{
  "terminal.integrated.profiles.windows": {
    "Git Bash": {
      "path": "C:\\Program Files\\Git\\usr\\bin\\bash.exe",
      "args": ["--login"]
    }
  },
  "terminal.integrated.defaultProfile.windows": "Git Bash",
  "terminal.integrated.shellIntegration.enabled": false
}

ポイント:

  • \usr\bin\bash.exeにする(\bin\じゃなくて)
  • シェル統合を切る

2. .bash_profile作る(オプション)

ターミナルで実行:

cat > ~/.bash_profile << 'EOF'
export MSYSTEM=MINGW64

if [ -f /etc/profile ]; then
    source /etc/profile
fi
EOF

3. Cursor再起動

全部閉じて開き直す。

4. 動いた!

$ uname -s
MINGW64_NT-10.0-22631

$ which bash
/usr/bin/bash

🎉

まとめ

  • パス: C:\Program Files\Git\usr\bin\bash.exe使う
  • シェル統合: 切る(falseにする)
  • .bash_profile: export MSYSTEM=MINGW64

これで動くようになった。

最後に

正直何やってるかよくわかってないけど、動いたからヨシ!👍
ちなみに、最初はCursorのエージェント、ChatGPT、Claudeにエラー投げてみたけど、.bashrc作り直したり.bash_profileいじったりされて色々試しても全然ダメだった。結局、そもそもパスが変なとこ向いてるのが原因だった。
教訓: 設定ファイルいじる前に、基本的なパスとか確認するの大事。見落としがち。
同じ問題で困ってる人の役に立てば嬉しいです。


環境:

  • Windows 10/11
  • Git for Windows
  • Cursor(VS Codeでも多分同じ)

参考設定:

// settings.json
{
  "terminal.integrated.profiles.windows": {
    "Git Bash": {
      "path": "C:\\Program Files\\Git\\usr\\bin\\bash.exe",
      "args": ["--login"]
    }
  },
  "terminal.integrated.defaultProfile.windows": "Git Bash",
  "terminal.integrated.shellIntegration.enabled": false
}
# ~/.bash_profile
export MSYSTEM=MINGW64

if [ -f /etc/profile ]; then
    source /etc/profile
fi
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?