Installing via rustup with sudo

I would like to install Rust via rustup on AWS Ubuntu, and I'd like sudo cargo to work. The system has a quirk that it wants SSH to log in via a regular user and then sudo to perform any actions.

If I install rustup as recommended curl | sh, then it's installed for the current user, and is not available in scripts ran via sudo.

If I install it via curl | sudo sh, then it creates unusable installation (warning: $HOME differs from euid-obtained home directory: you may be using sudo).

I need to use sudo cargo, because I'm building code that is not supposed to be world-readable, but I don't have patience to set up users/groups precisely :slight_smile:

Try curl | sudo -i sh? sudo -i creates a new login environment, and overrides a few more environment variables than bare sudo does.

You could also enter the shell via sudo su and then run the Rust installation script from there.