Nono.MA

JANUARY 18, 2024

First, you must install Rust in your machine, which comes with Cargo. (Installing Rust with rustc will also install Cargo.)

Create a new package

cargo new my_package

Build and run your package

cd my_package
cargo build
cargo run

Adding dependencies

Edit Cargo.toml and add your package dependencies.

// Cargo.toml
[dependencies]
base64 = "0.21.7"

You can browse Cargo packages at crates.io.

See how to compile and run Rust programs without Cargo.

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

Want to see older publications? Visit the archive.

Listen to Getting Simple .