Cargo install package

I used to have a script that would install some cargo packages as follows:

#!/usr/bin/env bash

set -oue pipefail
ln -sf /usr/bin/ld.bfd /etc/alternatives/ld && ln -sf /etc/alternatives/ld /usr/bin/ld

cargo install --root /usr nu
cargo install --root /usr swayr

Since approximatively a week this script fails with an error about /root/.cargo directory.

How should I install cargo packages into an image now?

Is your script called from a Dockerfile? It is not really clear what your image building process is.

I added the script to the recipe.yml file of my personal silverblue-nvidia fork, like this:

  - type: script
    scripts:
      # this sets up the proper policy & signing files for signed images to work
      - signing.sh
      - cargo.sh   # this script installs rust packages from cargo.io

The whole fork is on github GitHub - ecocode/ec-silverblue-nvidia: This is my personal Silverblue Nvidia image.

I finally found rpm packages of the cargo packages I need. So I disabled the cargo install script.
So my problem is solved for now, but still I’d like to know how cargo packages would directly be build into the image.