ホーム 格闘技 I got stuck in PATH hell with 'command not found' after installing Claude Code on Mac

I got stuck in PATH hell with 'command not found' after installing Claude Code on Mac

東條 淳平 東條 淳平 • 更新: • 公開: • 読了約 9 分
目次

When I tried to install the popular autonomous AI coding tool 'Claude Code' on my Mac, I got stuck in 'PATH hell' where it would revert to 'claude: command not found' every time I reopened the terminal, even after following the official instructions.

For those who have fallen into the same trap, I am leaving this as a memo for the ultimate procedure taught to me by Gemini, which solves it in one go with brute force without having to struggle with configuration files (.bashrc or .zshrc).

Environment

n0bfa8c3add06

Model: MacBook Pro M4 14-inch
OS: Tahoe 26.3 (25D125)
Shell: bash

What was happening?

The native installation recommended by the official source (curl command) displays a message like the following at the end.

 Setup notes:
 • Native installation exists but ~/.local/bin is not in your PATH. Run:
 echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.bashrc && source ~/.bashrc

If you run the command as instructed, the claude command will work for that session.However, when you restart the terminal, it reverts to 'command not found' again.

What is the cause?

The main Claude executable is installed in a hidden folder called ~/.local/bin. The official instructions are meant to 'teach the Mac the location of this hidden room (add it to PATH)', but due to differences in shells (bash or zsh) depending on the Mac version and the order in which configuration files are loaded,the Mac was forgetting that rule every time I opened the terminal which was the cause.

Solution: Create a symbolic link (shortcut)

Giving up on teaching the Mac the rules every time,the most reliable method is to place a shortcut (a 'wherever door') to the main Claude executable in a standard location that the Mac always checks from the start (/usr/local/bin).

With the following 3 steps, you will be able to use the claude command forever.

1: Clean up past remnants (for those who have installed it via npm)

I made a mistake and installed the npm version beforehand... If you have installed the npm version in the past, delete it to prevent conflicts.

Bash

npm uninstall -g @anthropic-ai/claude-code

2: Install the native version

Run the officially recommended command.

Bash

curl -fsSL https://claude.ai/install.sh | bash

* Pleasecompletely ignore the 'Setup notes: echo...' instructions that appear at the end here.

3: Create the magic shortcut (the ultimate technique)

Run the following command in your current terminal.

Bash

sudo ln -sf "$HOME/.local/bin/claude" /usr/local/bin/claude

* Since you are using sudo, you will be asked for your Mac login password. Nothing will appear on the screen when you type it, but just type it in and press Enter.

Verification

Close the terminal completely once, then open a new terminal.

Bash

claude -v

If the version (e.g., 2.1.50) is displayed, you have completed the perfect environment where it will launch anytime, anywhere, whether in the VS Code terminal or the standard Mac terminal!

Finally

I've been having more opportunities to look at code for work, so I installed Claude Code to try developing on my own with the help of AI. I was discouraged by being tripped up right from the start, but it really shows the times that I ended up needing AI to help me install AI...
I'm not sure if this error occurred because of my specific environment, but if you've fallen into the same trap, it might be worth a try.

Now that the environment is set up, I'll be developing with Claude Code!
I'll try to post on note again if there's anything else I want to share.

同じカテゴリの記事

東條 淳平

スポーツと芸能が交差する話題を担当。大会公式記録と所属先の発表を突き合わせ、数字は必ず出典付きで扱います。

おすすめの関連記事