How to rustup update when permission is denied?

4.3k views Asked by At

When I ran rustup update, I got the following error:

info: syncing channel updates for 'stable-x86_64-unknown-linux-gnu'
error: could not create temp file /home/abc/.rustup/tmp/mbbafo7rtfs5aazi_file
info: checking for self-updates

  stable-x86_64-unknown-linux-gnu update failed - rustc 1.52.1 (9bc8c42bb 2021-05-09)

info: cleaning up downloads & tmp directories
thread 'main' panicked at 'Unable to clean up /home/abc/.rustup/downloads: Os { code: 13, kind: PermissionDenied, message: "Permission denied" }', src/utils/utils.rs:642:13
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Then, I tried to run sudo rustup update and got the following:

sudo: rustup: command not found

The output of ls -l /home/abc/.rustup/ is:

total 28
drwxr-xr-x 2 root root 4096 May 31 14:06 downloads
-rw-r--r-- 1 root root  102 May 31 14:06 settings.toml
drwxr-xr-x 2 root root 4096 May 31 14:06 tmp
drwxr-xr-x 3 root root 4096 May 31 14:06 toolchains
drwxr-xr-x 2 root root 4096 May 31 14:06 update-hashes
1

There are 1 answers

0
Brady Dean On BEST ANSWER

It looks like you installed the Rust toolchain using the root account. This can be fixed by changing the user and group permissions of .rustup.

sudo chown -R abc:abc /home/abc/.rustup
rustup update

If your /home/abc/.cargo is also owned by root you will probably want to fix that too.