claude-code - 💡(How to fix) Fix [BUG] Native installer self-update (2.1.111 → 2.1.112) truncates ~/.bash_profile, ~/.bash_aliases, ~/.zshrc to 0 bytes [1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#49615Fetched 2026-04-17 08:36:10
View on GitHub
Comments
1
Participants
2
Timeline
8
Reactions
0
Author
Timeline (top)
labeled ×5closed ×1commented ×1cross-referenced ×1

Error Message

Error Messages/Logs

  1. No visible error at upgrade time -- the update "succeeds."

Root Cause

The bug is especially nasty because:

  1. No visible error at upgrade time -- the update "succeeds."
  2. Existing SSH sessions keep working (they have .bashrc already sourced in-memory).
  3. Only the NEXT new SSH login reveals the break, making it easy to attribute to unrelated causes.
  4. If ~/.bash_aliases or ~/.zshrc had user content, it is silently lost with no backup.

Fix Action

Fix / Workaround

Workaround: rm ~/.bash_profile ~/.bash_aliases ~/.zshrc. Ubuntu's default ~/.profile then sources ~/.bashrc correctly on login.

Code Example

# File timestamps showing simultaneous damage (America/New_York, -0400).
# Observed after the shell rc files had already been repaired, so only
# the ~/.claude/ side still carries exact sub-second timestamps. The
# three shell files were observed at 0 bytes with mtime "Apr 16 19:36"
# -- same minute as the ~/.claude/ skeleton rewrite below.

$ stat -c '%y %s %n' ~/.claude/agents ~/.claude/commands ~/.claude/plugins/installed_plugins.json
2026-04-16 19:36:12.524618930 -0400   4096   $HOME/.claude/agents             (empty dir)
2026-04-16 19:36:12.524618930 -0400   4096   $HOME/.claude/commands           (empty dir)
2026-04-16 19:36:21.633640893 -0400    452   $HOME/.claude/plugins/installed_plugins.json

$ ls -la ~/.bash_profile ~/.bash_aliases ~/.zshrc   # as observed BEFORE repair
-rw-rw-r-- 1 user user 0 Apr 16 19:36 $HOME/.bash_aliases
-rw-rw-r-- 1 user user 0 Apr 16 19:36 $HOME/.bash_profile
-rw-rw-r-- 1 user user 0 Apr 16 19:36 $HOME/.zshrc

# Installed versions dir -- self-update mid-flight
$ ls -la ~/.local/share/claude/versions/
-rwxr-xr-x 1 user user 234871424 Apr 15 19:25 2.1.110
-rwxr-xr-x 1 user user 235842176 Apr 16 12:46 2.1.111
-rwxr-xr-x 1 user user 235846272 Apr 16 15:56 2.1.112

# Symlink flipped to 2.1.112 ~5 minutes AFTER the shell files were truncated
$ ls -la ~/.local/bin/claude
lrwxrwxrwx 1 user user 49 Apr 16 19:41 $HOME/.local/bin/claude -> $HOME/.local/share/claude/versions/2.1.112

# Symptom on next SSH login
$ ssh host
host$ claude --version
bash: claude: command not found     # alias gone, ~/.local/bin missing from PATH
host$ echo $MY_CUSTOM_ENV_VAR
                                    # empty -- .bashrc exports never ran
RAW_BUFFERClick to expand / collapse

Preflight Checklist

  • I have searched existing issues and this hasn't been reported yet
  • This is a single bug report (please file separate reports for different bugs)
  • I am using the latest version of Claude Code

What's Wrong?

During a background self-update from 2.1.111 to 2.1.112, the Claude Code native installer truncated three shell rc files in $HOME to 0 bytes:

  • ~/.bash_profile
  • ~/.bash_aliases
  • ~/.zshrc

The empty ~/.bash_profile silently breaks SSH login shells: bash's login-shell lookup order uses ~/.bash_profile if it exists (even at 0 bytes) and skips ~/.profile. On Ubuntu, ~/.profile is what sources ~/.bashrc. Result: every new SSH login shell loses all aliases, $PATH additions from .bashrc, and exported env vars.

The update also created empty ~/.claude/agents/ and ~/.claude/commands/ dirs and rewrote ~/.claude/plugins/installed_plugins.json -- all in the same second. No ~/.bash_profile.bak (or similar) was left behind. Pre-existing content in .bash_aliases/.zshrc (if any) would be destroyed without warning.

What Should Happen?

The installer should never write to ~/.bash_profile, ~/.bash_aliases, or ~/.zshrc. If shell integration is intentionally being installed, it should (a) append rather than truncate, (b) back up the original to a .pre-claude or .bak file, and (c) be documented in the release notes and visible to the user at upgrade time.

Error Messages/Logs

# File timestamps showing simultaneous damage (America/New_York, -0400).
# Observed after the shell rc files had already been repaired, so only
# the ~/.claude/ side still carries exact sub-second timestamps. The
# three shell files were observed at 0 bytes with mtime "Apr 16 19:36"
# -- same minute as the ~/.claude/ skeleton rewrite below.

$ stat -c '%y %s %n' ~/.claude/agents ~/.claude/commands ~/.claude/plugins/installed_plugins.json
2026-04-16 19:36:12.524618930 -0400   4096   $HOME/.claude/agents             (empty dir)
2026-04-16 19:36:12.524618930 -0400   4096   $HOME/.claude/commands           (empty dir)
2026-04-16 19:36:21.633640893 -0400    452   $HOME/.claude/plugins/installed_plugins.json

$ ls -la ~/.bash_profile ~/.bash_aliases ~/.zshrc   # as observed BEFORE repair
-rw-rw-r-- 1 user user 0 Apr 16 19:36 $HOME/.bash_aliases
-rw-rw-r-- 1 user user 0 Apr 16 19:36 $HOME/.bash_profile
-rw-rw-r-- 1 user user 0 Apr 16 19:36 $HOME/.zshrc

# Installed versions dir -- self-update mid-flight
$ ls -la ~/.local/share/claude/versions/
-rwxr-xr-x 1 user user 234871424 Apr 15 19:25 2.1.110
-rwxr-xr-x 1 user user 235842176 Apr 16 12:46 2.1.111
-rwxr-xr-x 1 user user 235846272 Apr 16 15:56 2.1.112

# Symlink flipped to 2.1.112 ~5 minutes AFTER the shell files were truncated
$ ls -la ~/.local/bin/claude
lrwxrwxrwx 1 user user 49 Apr 16 19:41 $HOME/.local/bin/claude -> $HOME/.local/share/claude/versions/2.1.112

# Symptom on next SSH login
$ ssh host
host$ claude --version
bash: claude: command not found     # alias gone, ~/.local/bin missing from PATH
host$ echo $MY_CUSTOM_ENV_VAR
                                    # empty -- .bashrc exports never ran

Steps to Reproduce

Unable to reproduce deterministically without a second clean host. Observed sequence:

  1. Host running Claude Code 2.1.111 via native installer (~/.local/bin/claude symlink).
  2. Claude Code background-downloads 2.1.112 to ~/.local/share/claude/versions/2.1.112 while an interactive session is active.
  3. Self-update post-install step fires at some point during or at the end of the active session.
  4. That step: a. Re-skeletons ~/.claude/agents/ and ~/.claude/commands/ (empty dirs). b. Rewrites ~/.claude/plugins/installed_plugins.json. c. Truncates ~/.bash_profile, ~/.bash_aliases, ~/.zshrc to 0 bytes. d. Terminates the active session.
  5. ~5 minutes later, ~/.local/bin/claude symlink is atomically flipped to 2.1.112.
  6. User opens a new SSH session: login shell reads empty ~/.bash_profile, skips ~/.profile, does not source ~/.bashrc. Aliases/PATH/env are gone.

Likely trigger: any 2.1.111 -> 2.1.112 native-installer auto-update on Linux where $HOME is the user's real home dir.

Claude Model

Opus

Is this a regression?

Yes, this worked in a previous version

Last Working Version

2.1.111

Claude Code Version

2.1.112

Platform

Anthropic API

Operating System

Ubuntu/Debian Linux

Terminal/Shell

Other

Additional Information

Host: Ubuntu 24.04.4 LTS (noble), bash 5.2.21, native installer path ~/.local/share/claude/versions/.

Workaround: rm ~/.bash_profile ~/.bash_aliases ~/.zshrc. Ubuntu's default ~/.profile then sources ~/.bashrc correctly on login.

The bug is especially nasty because:

  1. No visible error at upgrade time -- the update "succeeds."
  2. Existing SSH sessions keep working (they have .bashrc already sourced in-memory).
  3. Only the NEXT new SSH login reveals the break, making it easy to attribute to unrelated causes.
  4. If ~/.bash_aliases or ~/.zshrc had user content, it is silently lost with no backup.

extent analysis

TL;DR

The issue can be temporarily worked around by removing the truncated shell rc files, allowing the default ~/.profile to source ~/.bashrc correctly on login.

Guidance

  • The root cause appears to be the Claude Code native installer truncating shell rc files during a background self-update from 2.1.111 to 2.1.112.
  • To verify the issue, check the timestamps of the shell rc files (~/.bash_profile, ~/.bash_aliases, ~/.zshrc) and the ~/.claude/ directories to see if they were modified simultaneously.
  • To mitigate the issue, remove the truncated shell rc files using rm ~/.bash_profile ~/.bash_aliases ~/.zshrc, allowing the default ~/.profile to source ~/.bashrc correctly on login.
  • Be cautious when updating Claude Code, as this issue may occur again if the underlying problem is not fixed.

Example

No code snippet is provided, as the issue is related to the installer's behavior rather than a specific code snippet.

Notes

The issue is specific to the native installer on Linux, and the workaround may not be applicable to other platforms or installation methods. The fact that the issue is not immediately apparent and only reveals itself on the next new SSH login makes it challenging to diagnose.

Recommendation

Apply the workaround by removing the truncated shell rc files, as the root cause of the issue is not yet fixed in the current version of Claude Code. This will allow the default ~/.profile to source ~/.bashrc correctly on login, restoring the expected behavior.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

claude-code - 💡(How to fix) Fix [BUG] Native installer self-update (2.1.111 → 2.1.112) truncates ~/.bash_profile, ~/.bash_aliases, ~/.zshrc to 0 bytes [1 comments, 2 participants]