Nono.MA

Solved: Change the owner of the .cargo directory to fix os error 13

JANUARY 12, 2024

I got a Permission denied error when trying to cargo install.

› cargo install cargo-wasm
    Updating crates.io index
  Downloaded cargo-wasm v0.4.1
error: failed to download replaced source registry `crates-io`

Caused by:
  failed to create directory `/Users/nono/.cargo/registry/cache/index.crates.io-6f17d22bba15001f`

Caused by:
  Permission denied (os error 13)

This is how I fixed it.

sudo chown -R $(whoami) /Users/nono/.cargo

I then tried to cargo wasm setup and got this error.

› cargo wasm setup
info: syncing channel updates for 'nightly-aarch64-apple-darwin'
error: could not create temp file /Users/nono/.rustup/tmp/628escjb9fzjn4mu_file: Permission denied (os error 13)
Failed to run rustup. Exit code was: 1

Which, again, was solved by changing the owner of ~/.rustup to myself.

sudo chown -R $(whoami) /Users/nono/.rustup

BlogCodeCargoRust