[BUG] native install fails with EINVAL: invalid argument, copyfile '~/.cache/claude/staging/1.0.123/claude' -> ...
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?
When installing the native version of claude-code on Ubuntu 22.04.5 I get an error from copyfile. Apparently, the installation aborts, because when I type the command 'claude' in the terminal, I get "command not found".
I tried to remove all relevant files and directories and try again, but got the same error. Here is the command I used to remove leftovers from a failed install:
rm -rf ~/.cache/claude ~/.local/share/claude ~/.claude*
After manually copying '~/.cache/claude/staging/1.0.123/claude' to '~/bin', I can run 'claude', but 'claude doctor' complains: "Warning: Running native installation but config install method is 'unknown'". Also, this setup will probably fail when claude code tries to update to a new version.
What Should Happen?
Claude Code native should get installed in ~/.local/share/claude and runnable.
Error Messages/Logs
The error message is:
✘ Installation failed
EINVAL: invalid argument, copyfile '/home/user/.cache/claude/staging/1.0.123/claude' -> '/home/user/.local/share/claude/versions/1.0.123.tmp.1129780.1758754356342'
Try running with --force to override checks
Steps to Reproduce
Try to install native Claude Code as suggested in documentation: curl -fsSL https://claude.ai/install.sh | bash
Claude Model
None
Is this a regression?
I don't know
Last Working Version
No response
Claude Code Version
1.0.123 (Claude Code)
Platform
Anthropic API
Operating System
Ubuntu/Debian Linux
Terminal/Shell
Xterm
Additional Information
$ claude doctor
Diagnostics └ Currently running: native (1.0.123) └ Path: /home/user/bin/claude └ Invoked: /home/user/claude-bin/claude └ Config install method: unknown └ Auto-updates enabled: default (true) └ Search: OK (bundled) Warning: Running native installation but config install method is 'unknown' Fix: Run claude install to update configuration
$ cat /etc/os-release PRETTY_NAME="Ubuntu 22.04.5 LTS" NAME="Ubuntu" VERSION_ID="22.04" VERSION="22.04.5 LTS (Jammy Jellyfish)" VERSION_CODENAME=jammy
Same problem here:
curl -fsSL https://claude.ai/install.sh | bash Setting up Claude Code... ✘ Installation failed EINVAL: invalid argument, copyfile '/home/XXXX/.cache/claude/staging/1.0.127/claude' -> '/home/XXXX/.local/share/claude/versions/1.0.127.tmp.23967.1758986079378'
I cant find a solution, npm install does also NOT work
I believe I found the issue. It seems to be this: https://github.com/oven-sh/bun/issues/13968 So it seems to be related to an encrypted home directory.
running export BUN_CONFIG_DISABLE_COPY_FILE_RANGE=true lets the installation succeed
PS: I found the issue using strace. The last call was copy_file_range but the parameters seemed to be right. Glad to have found the issue reported with bun.
I believe I found the issue. So it seems to be related to an encrypted home directory.
Yes, my home directory is encrypted with ecryptfs.
running
export BUN_CONFIG_DISABLE_COPY_FILE_RANGE=truelets the installation succeed
Installing with BUN_CONFIG_DISABLE_COPY_FILE_RANGE=true fixed my problem. The latest Claude version installed successfully with no errors or warnings.
Thanks a lot!
Yes, my home directory is indeed encrypted. And yes, @neuron303 your solutions (export ...) works like a charm! Thank you very much. I reported a link to this issues back to [email protected] as I contacted them
I am running Linux Mint 22.2 with an encrypted home directory and had the same issue. Running export BUN_CONFIG_DISABLE_COPY_FILE_RANGE=true before running the native installer worked for me.
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.
The error is still not fixed.
When I try to update Claude Code without BUN_CONFIG_DISABLE_COPY_FILE_RANGE=true I get the same error:
$ claude update
Current version: 2.0.53
Checking for updates...
Error: Failed to install native update
Error: EINVAL: invalid argument, copyfile '/home/aoand/.cache/claude/staging/2.0.65/claude' -> '/home/aoand/.local/share/claude/versions/2.0.65.tmp.543657.1765451323428'
Try running "claude doctor" for diagnostics
As I understand it, the problem is that some filesystems don't support the copy_file_range system call and return EINVAL. Bun uses this syscall during installation (arguably without good reason, since the speed improvement is negligible, if any), which causes the installation to abort. Specifically ecryptfs is known to be problematic: bun: copy_file_range is not supported on eCryptfs.
The fix could be either always use "traditional" copy routine instead of copy_file_range, or retrying with "traditional" copy when copy_file_range returns EINVAL.