What is the recommended way to install Rust on Manjaro Linux?

I have installed Rust on my Manjaro system recently following these installation steps

To install Rust on Manjaro Linux, follow these steps:

  1. Update Manjaro: Before installing Rust, ensure your system is up-to-date by running sudo pacman -Syu in the terminal[1].

  2. Install Rust: Use the following command to install Rust on Manjaro Linux:
    curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh[2].

  3. Activate Rust Environment: After installation, activate the Rust environment for your current shell using source "$HOME/.local/share/cargo/env".

To get started you need Cargo's bin directory
(/home/user/.local/share/cargo/bin) in your PATH
environment variable. This has not been done automatically.

To configure your current shell, run:
source "/home/user/.local/share/cargo/env"

❯ source "/home/user/.local/share/cargo/env"

❯ echo $PATH
/home/user/.local/share/cargo/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/home/user/.local/bin:/home/user/.cargo/bin:/home/user/.config/node_modules/bin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:/var/lib/snapd/snap/bin
  1. Verify Installation: Check if Rust is successfully installed by running rustc -V in the terminal.
❯ rustc -V
rustc 1.77.0-beta.5 (f2043422f 2024-02-17)
  1. Test Rust Installation: Create a test program like “Hello, World!” by creating a file named main.rs, adding fn main() { println!("Hello, World!"); }, and compiling it with rustc main.rs && ./main[1].
❯ echo 'fn main() { println!("Hello, World!"); }' > main.rs
rustc main.rs && ./main
Hello, World!
  1. Update Rust: Keep your Rust installation up-to-date with rustup update to get the latest features and security patches[2].

  2. Uninstall Rust: If needed, you can remove Rust from your system using rustup self uninstall[1].

By following these steps, you can easily install, test, update, and remove Rust on your Manjaro Linux system.

Citations:
[1] https://www.linuxcapable.com/how-to-install-rust-on-manjaro-linux/
[2] Install Rust - Rust Programming Language
[3] rust
[4] What is the recommended way to install rust on Arch? / Applications & Desktop Environments / Arch Linux Forums
[5] Update replaces rustup with rust

Later when I tried to install a package that required Rust using the Pamac package manager, I got a message to “Choose a provider for cargo” and I have to choose between rust and rustup.

This made me wonder - what is the recommended way to install Rust on Manjaro Linux? Should I be using the command above to install rustup or installing from the repo with Pamac? And why did the package not recognize my existing rustup installation?

Any clarification would be appreciated so I can get Rust properly set up on my system.

Thanks!

What did you try? There is rust in the packages and for development, rustup.

https://wiki.archlinux.org/title/Rust

2 Likes

I uninstalled the previous and installed it from the repo and I no longer have the previous issue when installing another package.

❯ rustup self uninstall
❯ yay -Sy rustup
❯ rustup default stable

This is decidedly the wrong way to install packages.

sudo pacman -Syu rust

(when installing it might make sense to sync+upgrade at the same time. But we never sync without upgrading. -S is OK, -Syu is probably better, but -Sy never [excepting very specific keyring troubleshooting])

This topic was automatically closed 36 hours after the last reply. New replies are no longer allowed.