[BUG] Claude code CLI binary installer silently deletes itself after installation

Open 💬 19 comments Opened Sep 13, 2025 by apathi

Preflight Checklist

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

What's Wrong?

🐞 BUG: Claude Code CLI binary silently deletes itself after installation

Summary

After installing Claude Code using the official script (https://install.anthropic.com/code), the binary located at ~/.local/bin/claude is silently deleted by a background node process within minutes, making the CLI unusable. This occurs without user interaction.

Steps to Reproduce

# 1. Install Claude
curl -sS https://install.anthropic.com/code | sh

# 2. Verify it's installed
which claude        # -> ~/.local/bin/claude
claude --version    # -> 1.0.112

# 3. Wait a few minutes, then try again
which claude        # -> not found

---

Root Cause Evidence

Using fs_usage, I captured this exact unlink event:

02:56:20.477495  unlink  /Users/apathi/.local/bin/claude  node.7897450

So node unlinked the binary silently, with no user input.

The process ran silently in the background and removed the claude binary after it had been successfully installed and verified. The process is node, likely from the package: @anthropic-ai/claude-code@1.0.44. No confirmation or fallback install happens. Leaves CLI completely unusable until reinstalled.

📦 Related Context

npm list -g --depth=1 | grep claude
├─┬ @anthropic-ai/claude-code@1.0.44
  • The binary is installed to: ~/.local/bin/claude
  • There’s no ~/.local/lib/node_modules/claude/ directory (suggesting cleanup or postinstall deletion or a faulty updater )
  • .npm/_logs shows high activity around the deletion time

---

📅 Timeline Summary

| Time (PDT) | Event |
|-----------:|:------|
| 02:43 AM | Ran install script |
| 02:44 AM | Verified CLI works |
| 02:56 AM | claude binary deleted by node |
| 02:58 AM | Confirmed missing CLI in shell |

---

What Should Happen?

💥 Expected Behavior

  • The CLI should not delete its own binary silently.
  • Any updates or postinstall actions should verify success before unlinking anything.
  • Binaries should not be unlinked unless rollback/replace is guaranteed.
  • Silent self-deletion without user interaction breaks CLI workflows and trust.

---

🧠 System Info

  • macOS: 14.x (Apple Silicon, MacBook Air M3)
  • Claude Code Version: 1.0.112
  • Node Version: node -v = v v24.3.0
  • npm Version: npm -v = 11.4.2
  • Install Script Used: https://install.anthropic.com/code

---

Error Messages/Logs

## 📎 Supporting Logs

**Attached:**

- `fs_usage.log` ← confirms deletion timestamp
- `dtruss_claude.log` ← shows launch-to-deletion flow
- `opensnoop_launcher.log` / `opensnoop_share.log` ← traces I/O ops
- `.npm/_logs/*.log` ← shows background npm/node activity at exact time

---

Steps to Reproduce

Steps to Reproduce

# 1. Install Claude
curl -sS https://install.anthropic.com/code | sh

# 2. Verify it's installed
which claude        # -> ~/.local/bin/claude
claude --version    # -> 1.0.112

# 3. Wait a few minutes, then try again
which claude        # -> not found

---

Claude Model

Opus

Is this a regression?

Yes, this worked in a previous version

Last Working Version

1.0.98

Claude Code Version

1.0.112

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

Terminal.app (macOS)

Additional Information

📎 Supporting Logs

Attached:

  • fs_usage.log ← confirms deletion timestamp
  • dtruss_claude.log ← shows launch-to-deletion flow
  • opensnoop_launcher.log / opensnoop_share.log ← traces I/O ops
  • .npm/_logs/*.log ← shows background npm/node activity at exact time
  • watch-claude.sh - The Script to reproduce and live-monitor the deletion we created . This script

• Installs Claude
• Locks the binary
• Starts monitoring with:
• fs_usage
• dtruss
• opensnoop
• and date-based command -v claude watcher

🙏 Let me know

  • Is it an auto-update issue?
  • Can I disable the background self-deletion?

Happy to test fixes, betas, or submit more data. Thanks for this excellent tool — hope this helps make it more robust!


[dtruss_claude.log](https://github.com/user-attachments/files/22309440/dtruss_claude.log)
[opensnoop_launcher.log](https://github.com/user-attachments/files/22309438/opensnoop_launcher.log)
[opensnoop_share.log](https://github.com/user-attachments/files/22309439/opensnoop_share.log)

[watch-claude.sh](https://github.com/user-attachments/files/22309443/watch-claude.sh)

View original on GitHub ↗

19 Comments

psihonavt · 10 months ago

Just wanted to +1 this issue – it has happened to me at least two times (OS X, claude installed using npm -g).

apathi · 10 months ago

Update for anyone following this issue — the problem no longer occurs when installing Claude using the new binary installer released today Sept 15 2025:

✅ New install (working):
curl -fsSL https://claude.ai/install.sh | bash

❌ Old install :
curl -sS https://install.anthropic.com/code | sh

After testing on the same system for several hours, the issue thus far appears to be resolved when using the new install script. Happy to share logs or more details if helpful.

apathi · 10 months ago

Without any user action or interference on my part, the installed path and version of claude changed unexpectedly. Additionally, I’m now receiving a warning about multiple installations when running /doctor.

Earlier – September 09, 2025 at 03:32 PM

which claude
/Users/[username]/.local/bin/claude

claude --version
1.0.115 (Claude Code)

Now – September 09, 2025 at 11:49 PM

which claude
/opt/homebrew/bin/claude

claude --version
1.0.117 (Claude Code)

Current Behavior : When I run /doctor, I get the following warning:

Warning: Multiple installations found
└ npm-global at /opt/homebrew/bin/claude
└ native at /Users/[username]/.local/share/claude

Notes

  • I did not manually upgrade or reinstall claude.
  • No configuration changes or environment variable updates were made by me between the two timestamps.
  • Seems like the auto updater bumped the version up and the active path was switched from the local install to a global one (/opt/homebrew/bin).
  • Concerned that this may lead to conflicting behavior or future issues with updates or my environment management.
oscar-edomex · 9 months ago

Experiencing similar issues with npm global installation on macOS (Apple Silicon). This has now happened 3 times in the past week.

System Info

  • macOS: Darwin 24.6.0 (Apple Silicon)
  • Node Version: v22.18.0 (via nvm)
  • npm Version: v11.5.2
  • Install Method: npm install -g @anthropic-ai/claude-code
  • Claude Code Version: 2.0.10

Symptoms

After successful installation, the claude command breaks between sessions. Running which claude returns claude not found.

Root Cause

Investigation shows:

  1. Broken symlinks in /Users/[username]/.nvm/versions/node/v22.18.0/bin/:

``bash
lrwxr-xr-x .claude-SU8Nu63Y -> ../lib/node_modules/@anthropic-ai/claude-code/cli.js
``

  1. The symlink points to a non-existent file (target cli.js doesn't exist)
  2. The actual installation directory /Users/[username]/.nvm/versions/node/v22.18.0/lib/node_modules/@anthropic-ai/claude-code/ exists but is incomplete/corrupted

Errors During Reinstall Attempts

npm error code ENOTEMPTY
npm error syscall rename
npm error path /Users/[username]/.nvm/versions/node/v22.18.0/lib/node_modules/@anthropic-ai/claude-code
npm error dest /Users/[username]/.nvm/versions/node/v22.18.0/lib/node_modules/@anthropic-ai/.claude-code-PzqBIps8
npm error errno -66
npm error ENOTEMPTY: directory not empty, rename...

Workaround That Works

# 1. Manually remove the corrupted installation
rm -rf ~/.nvm/versions/node/v22.18.0/lib/node_modules/@anthropic-ai/claude-code
rm -f ~/.nvm/versions/node/v22.18.0/bin/.claude-*

# 2. Reinstall
npm install -g @anthropic-ai/claude-code

This fixes it temporarily, but the issue recurs after laptop goes to sleep overnight with the CLI open and also with opening up a terminal session the next day and attempting to run claude

Question

Similar to @apathi's question: Is this related to an auto-updater that's silently failing and leaving the installation in a corrupted state? The ENOTEMPTY errors suggest npm's atomic operations are failing mid-update.

mattsadmin · 9 months ago

I'm using the native version of Claude on Windows, and I’ve encountered a strange behavior. When I run claude.exe, it creates a copy of itself in the same folder—but this copy is a zero-byte file also named claude.exe.

I’ve tried reinstalling the app using both npm and the Windows-native installer, but the result is the same: during installation, a zero-byte claude.exe gets downloaded or created. To troubleshoot, I restored a backup of the working claude.exe into the same folder. When I ran it, I noticed through File Explorer that the app tries to rename itself and again creates a zero-byte file.

Here’s where it gets more interesting: I renamed my backup to claude2.exe and ran that instead. This time, it still created a zero-byte claude.exe in the same folder, but it didn’t try to rename or overwrite claude2.exe.

Questions:

Is this self-copying and creation of a zero-byte claude.exe file an intentional behavior from Anthropic?

Or is this a bug in the native app?

Temporary Workaround:

If you're using the native version and run into this issue, you can retrieve a working .exe from a previous version by navigating to:

C:\Users\<your-username>\.local\share\claude\versions

Look for a version folder that contains a valid (non-zero-byte) .exe file. Copy it, rename it (e.g., claude2.exe), and run that instead.

apathi · 8 months ago

Update: Issue Reproduced

The silent deletion issue occurred again - Claude Code disappeared from my system through what appears to be a background process, prompting me to reinstall.

This time I reinstalled using the new Homebrew installation method (Claude Code ~2.0.x).
When reinstalling Claude Code via Homebrew, there is a conflict between two update mechanisms :

  • Claude's built-in auto-updater → installs to ~/.local/bin/claude
  • Homebrew → installs to /opt/homebrew/Caskroom/ (or /usr/local/)

Not sure iff this is was causing the silent deletion issue.

Issue : Disabling the Auto-Updater

When re-installing claude code the official method provided by claude code installer is broken:

claude config set autoUpdates false

⚠️ This command just opens Claude instead of setting the configuration.

The alternative solution provided works:

i.e add this environment variable to your shell config:

  • macOS: ~/.zshrc (default shell)
  • Linux: ~/.bashrc (default shell)

````bash

For macOS (zsh)

echo -e "\n# Disable Claude Code auto-updater (managed by Homebrew)\nexport DISABLE_AUTOUPDATER=1" >> ~/.zshrc
source ~/.zshrc

Hopefully disabling the auto-updater, Claude Code updates only through Homebrew, eliminating the silent deletion issue faced multiple times.
wormholecowboy · 7 months ago

This is still happening to me on MacOS as well. Switching to homebrew install to see if that is more stable.

github-actions[bot] · 6 months ago

This issue has been inactive for 30 days. If the issue is still occurring, please comment to let us know. Otherwise, this issue will be automatically closed in 30 days for housekeeping purposes.

johnbcoughlin · 6 months ago

I am experiencing this issue today after using the up to date recommended installation instructions. Do not automatically close this issue.

dkovach · 6 months ago

This has just happened to me - I had the npm version in a Github Codespace... Gemini still there, Claude gone...

dkovach · 6 months ago

@wormholecowboy did that solve it? It is so random - days and days with this repo instance and months and I have never seen something so unexpected... So when you reinstall you lose all your conversations???

wormholecowboy · 6 months ago

Yeah, seems to have solved it. I have not had the problem since. Not sure
on conversations, but I would just backup that folder and migrate
afterwards.

On Sat, Jan 10, 2026 at 3:14 PM David Kovach @.***>
wrote:

dkovach left a comment (anthropics/claude-code#7547) <https://github.com/anthropics/claude-code/issues/7547#issuecomment-3733455346> @wormholecowboy <https://github.com/wormholecowboy> did that solve it? It is so random - days and days with this repo instance and months and I have never seen something so unexpected... So when you reinstall you lose all your conversations??? — Reply to this email directly, view it on GitHub <https://github.com/anthropics/claude-code/issues/7547#issuecomment-3733455346>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AVSXNWIXJWW5D5EH7ZNQLSD4GFMSNAVCNFSM6AAAAACGM44NSSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTOMZTGQ2TKMZUGY> . You are receiving this because you were mentioned.Message ID: @.***>
KingSupernova31 · 5 months ago

This just happened to me; Claude was working fine for months and then one day up and deleted itself. (Since it wasn't immediately after install my issue may be better described by #2357 or #9327, but those have been locked for some reason.)

CanvasCodeLtd · 5 months ago

Woke up today... "zsh: command not found: claude"

I had to run to fix: echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.zshrc && source ~/.zshrc

FullMetalResearcher · 5 months ago

Happened again to me. It's the third time in a month

puckettventures · 5 months ago

This just happened to me after I ran out of tokens. FYI.

nezaj · 5 months ago

Just wanted to +1 this happens to me too. Not sure why

$ npm list -g --depth=1 | grep claude

├─┬ @anthropic-ai/claude-code@2.1.14

and yet

$ which claude
claude not found

Update

Was able to get back into a happy state by

rm -rf <path_to_npm_claude> # delete claude npm package
npm i -g @anthropic-ai/claude-code. # re-install it
claude # run claude

This then informed me there is a new way to install claude natively via claude install

After that I got instructions to update my path to include the location of native install

Native installation exists but ~/.local/bin is not in your PATH.

And now I get

$ which claude
/Users/nezaj/.local/bin/claude

Also removed the npm package once more

opriz · 4 months ago

FYI, I use Cursor agent fixed my similar problem, here is it's conclusion:

npm package layout: The @anthropic-ai/claude-code package is installed under .claude-code-2DTsDk1V, and cli.js lives in that directory. Broken symlink: npm created a symlink in /opt/homebrew/bin/ pointing to @anthropic-ai/claude-code/cli.js, but that path does not contain cli.js, so the symlink is invalid. Unexpected symlink name: Because of a conflict, the symlink was created as .claude-WV2akNWU instead of claude, so the claude command was never available. Fix Applied Removed the broken symlink: /opt/homebrew/bin/.claude-WV2akNWU Created a new symlink: /opt/homebrew/bin/claude → actual path of cli.js