Comments on How to Install Rust Programming Language on Debian 11

In this guide, you will learn how to install Rust programming language on the Debian 11 Bullseye. We will be using the rustup toolchain for installing and managing Rust on the Debian system.

5 Comment(s)

Add comment

Please register in our forum first to comment.

Comments

By: Taleman

Why not

apt install rustc

By: Roelof Berkepeis

thank you!  this procedure helped me to setup Rust and Rustup on my Devuan Chimaera 4.0 (a Debian 11 derivative) .. but i have some remarks :after seeing 'Rust is installed now. Great!' the text in terminal shows :To configure your current shell, run:source /opt/rust/envi did NOT do this, i just followed your procedure and all seems to have gone OK.later, i also did this command, which you mention :rustup completions bash > /usr/share/bash-completion/completions/rustupbut it gave the error "Permission denied" .. so, i needed to give write permissions to the folder /usr/share/bash-completion/completions/ !?another issue, which i don't understand, is this : when NOT being sudo, the command 'rustc --version' gives nothing : it says rustc is not installed !? Indeed, according to Synaptic, 'rustc' is NOT installed .. Synaptic also shows 'cargo' is NOT installed !? But when i do "su - [username]" and then 'rustc --version', it says that it IS installed, and also cargo .. can you explain ?

By: Tom Dial

@Taleman:

apt install rustc will work, but only install cargo, libstd-rust-1.63, libstd-rust-dev, and rustc (on bookworm - earlier versions may be installed on bullseye). The current applicable versions are later, and this will lead to failures installing components using rustup in its normal way. Most of the items are likely in the Debian repositories, and could be installed using apt, but they will, similarly, not necessarily be the most up to date.

The above procedure will install under /opt and not interfere either with Debian operation or updating.

By: Tom Dial

@Roelof Berkepeis:

The description above is not always clear about which account - root or ordinary user - is to be used. Any of the commands that update system files under /usr or /etc need to be run as root, whether logged in as root or using sudo. These include the modifications to /usr/share/bash-completion/ and /etc profile.d/. For security reasons, it is a bad idea to allow anyone but root write permissions in such directories.

Ordinarily, when files that set environment variables are changed it is necessary to either set the variables explicitly or to logout and login again. Using su - to change user id has the same effect.

This install procedure does not affect the databases used by apt, aptitude, apt-get and synaptic; none of them will show that Rust is installed. However, if the procedure is completed correctly, Rust and its core components will be installed and usable from any login account on the system.

By: Tom Dial

I'm entirely new to Rust, but not to Linux.

The instructions here do not mention making CARGO_HOME either global or permanent (per login). Some rustup executions appear to require it:

root@euler:~# echo $CARGO_HOMEroot@euler:~# rustup updateinfo: syncing channel updates for 'stable-x86_64-unknown-linux-gnu'info: syncing channel updates for 'nightly-x86_64-unknown-linux-gnu'error: rustup is not installed at '/root/.cargo'

vs

root@euler:~# export CARGO_HOME=/opt/rustroot@euler:~# rustup updateinfo: syncing channel updates for 'stable-x86_64-unknown-linux-gnu'info: syncing channel updates for 'nightly-x86_64-unknown-linux-gnu'info: checking for self-updates   stable-x86_64-unknown-linux-gnu unchanged - rustc 1.67.1 (d5a82bbd2 2023-02-07)  nightly-x86_64-unknown-linux-gnu unchanged - rustc 1.69.0-nightly (31f858d9a 2023-02-28)info: cleaning up downloads & tmp directories

Is this an oversight or done for a reason? Either way, it seems worth mentioning in the section on managing Rust.