Native install appends PATH export to ~/.bashrc on every GUI launch (921 duplicate lines)

Status Open
Reported on v2.1.220
Maintainer reply None cached
Activity 0 comments · opened Jul 28, 2026

Summary

On a native install launched from a GUI app, Claude Code appends export PATH="$HOME/.local/bin:$PATH" to ~/.bashrc repeatedly and without bound. My ~/.bashrc accumulated 921 identical copies of the line (924 lines total; only 3 lines were mine).

The resulting PATH had 1,853 entries, 26 of them unique~/.local/bin appeared 1,827 times. Every command lookup scans that list.

Environment

  • Claude Code 2.1.220 (native install, installMethod: native)
  • macOS 24.6.0 (arm64), bash
  • Launched via a GUI wrapper app (not from a terminal)

Root cause (as far as I can tell)

The idempotency guard appears to test the running process's PATH env var rather than whether the line already exists in the rc file. That check can never succeed under a GUI launch:

  1. GUI-launched apps on macOS inherit the launchd default PATH. On this machine there is no launchctl setenv PATH, so it's the bare system default:

``
$ sysctl -n user.cs_path
/usr/bin:/bin:/usr/sbin:/sbin
`
~/.local/bin` is not present.

  1. Claude Code sees ~/.local/bin missing from PATH and appends the export to ~/.bashrc.
  2. ~/.bashrc is only sourced by interactive bash shells — never by the GUI app. So the process PATH is unchanged on the next launch.
  3. Condition never clears → appends again, forever.

This is consistent with the append being independent of updates: only 3 versions were present in ~/.local/share/claude/versions/, so this is not a once-per-upgrade write.

Reproduction

  1. Native-install Claude Code on macOS.
  2. Launch it from a GUI app / launcher rather than a terminal (so the process PATH lacks ~/.local/bin).
  3. grep -c 'local/bin' ~/.bashrc — watch it climb.

Evidence that it regrows immediately

After truncating ~/.bashrc to 4 legitimate lines, a fresh duplicate reappeared within minutes, while the session was still open:

$ wc -l < ~/.bashrc
4
# ... a few minutes later ...
$ cat ~/.bashrc
export PATH="$HOME/.local/bin:$PATH"

# Agent Launcher binary path
export PATH="$PATH:/Users/…/.config/agent-portal"
export PATH="$HOME/.local/bin:$PATH"     ← newly appended

I also observed the file grow 922 → 923 → 924 lines over the course of a single session, so it is appending more than once per startup.

Suggested fix

Before appending, grep the target rc file for the line (or a marker comment) and skip if present. A file-content check is correct here; a process-PATH check cannot work for rc files the launching process never sources.

A marker such as # added by claude-code would also let users and the installer identify prior writes.

Impact

Unbounded growth of a user shell config file, plus a PATH that grows without limit and slows every command lookup in every shell. Silent — nothing surfaces it until you read ~/.bashrc.

View original on GitHub ↗