Bug: Claude Code Installer Improperly Modifies ~/.zshrc Without Newline Separation
Resolved 💬 1 comment Opened Apr 30, 2026 by RhysEJF Closed May 31, 2026
Bug Report: Claude Code Installer Improperly Modifies ~/.zshrc
Summary
Claude Code CLI auto-update process appends export PATH="$HOME/.local/bin:$PATH" to ~/.zshrc without a preceding newline, causing shell syntax errors.
Environment
- OS: macOS Darwin 24.6.0
- Shell: zsh
- Claude Code Version: 2.1.123 (auto-updated from 2.1.121/2.1.122)
- Date: April 29-30, 2026
Bug Description
During automatic updates (versions 2.1.121 → 2.1.122 → 2.1.123), the installer appended the PATH export line directly after the closing brace } of an existing function in ~/.zshrc without adding a newline separator.
Before (working):
esac
}
After (broken):
esac
}export PATH="$HOME/.local/bin:$PATH"
This created invalid shell syntax: }export on the same line, preventing ~/.zshrc from loading and causing "claude: command not found" errors.
Impact
- Complete shell startup failure
- Claude CLI inaccessible until manual fix
- Potential data loss risk if users don't understand the issue
Reproduction
- Have an existing ~/.zshrc with functions
- Allow Claude Code to auto-update
- Shell configuration gets corrupted
Expected Behavior
Installer should:
- Check for existing content in shell config files
- Add proper newline separation before appending
- Validate shell syntax after modification
Actual Behavior
Installer blindly appends without newline separation, breaking shell syntax.
Suggested Fix
Add newline validation to installation scripts:
# Ensure file ends with newline before appending
if [ -s ~/.zshrc ] && [ "$(tail -c1 ~/.zshrc | wc -l)" -eq 0 ]; then
echo "" >> ~/.zshrc
fi
echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.zshrc
Additional Context
- This appears to be a common installer antipattern
- Similar issues reported with other CLI tools
- Binary signature verified as legitimate Anthropic release
Verification Details
- Binary Hash: 44597dff0f1c11e37c1954d4ac3965909be376e5961b558345723357253bcc90
- Code Signature: Valid, Team ID Q6L2SF6YDW
- Timestamp: Apr 29 02:57:58 2026
This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗