HowTo: install local rust packages with cargo on atomic desktops

This is a general guide not ony for atomic desktops.

For various reasons you might want to install rust packages (called “crates”) with the rust package manager cargo.

These not only include libraries or development requirements, but also packages you might want, while avoiding layering them.

1. Install rust locally

This is the officially recommended way.

Go to your home directory

cd

run their official script

(To avoid outdated information I will not quote it here)

This should also install cargo.

2. Add cargo to your path

The rustup installer should set things up or tell you what you need to do.

Make sure this is in your path: $HOME/.cargo/bin

On bash or zsh:

echo "PATH=$PATH:$HOME/.cargo/bin" >> ~/.bashrc

On fish:

mkdir -p ~/.config/fish/conf.d
echo "set PATH PATH:$HOME/.cargo/bin" >> ~/.config/fish/conf.d/rustup.fish

Exit the shell (close the terminal or terminal tab) and reopen it, it should be applied.

3. Set up cargo

This is required. Again, stay in your home directory

cargo init

Now you can install whatever you want using cargo install x, example:

cargo install sddm2rpm

For a workaround to create RPMs you can layer for SDDM themes (on Kinoite or other variants using the SDDM login manager)

Exceptions

Sometimes you may not be able to use install, as a package may be listed as a library.

So make sure you are in your home directory and use cargo add x instead.

cargo binstall

cargo compiles the packages and all requirements on installation locally, which is a security and performance measurement.

But if you want to skip this and instead use available binaries, you need the binstall addition.

Upstream install instructions:

cargo install cargo-binstall

Alternatively, you can use these instructions for the linux install script, but there should be no need, if you alreay have a recent rust and cargo installed. You might be able to skip these steps though.

Now you can install binaries without compiling, from their binary package repo.

cargo binstall x

Stay updated

To update the rust installer rustup, the rust language and compiler, and the package manager cargo:

rustup update

To upgrade all installed rust crates with cargo:

cargo install cargo-update
cargo install-update -a

Check versions

cargo --version
rustc --version
rustup --version

Why to do things so complicated

Toolbox and install rust done

To update just run rustup update

2 Likes

Installing in a toolbox does add an entire Fedora container which is worlds more complex and will download gigabytes of more data over time.

Also more complex to add to PATH, slower, more RAM consumption.

Thanks for the rustup command. Online sources seem to overcomplicate things

So what is the point using atomic that is made for containers and containerized development if installed all as layers and local…

And not sure how toolbox container can take gigabytes of storage same does local install and makes your home glutter and opens up for threats

But yeah there is as many use cases than users on modern computer era

This is going off topic, not gonna discuss this here.

Feel free to open another thread on this