What are your expectations about Rust installation by a non-priveleged user?

There's an issue on GitHub about rustup.sh - that it could detect installation by non-root user and switch to single-user installation mode automatically.

I think it's a good idea to install stuff locally - it's easier to manage and remove, users can have different installations, etc.

It could use $HOME/install or something similar as prefix if the user is not root, but there are several problems.

If we are to install to user directory, we need to update user's environment. Meaning, we need at least to add $HOME/install/bin to $PATH and $HOME/install/lib to $LD_LIBRARY_PATH. There are several options on doing that:

  • We could update .profile, but it's not run in all situations, and order and set of startup files is heavily dependent on current login shell and other setup.
  • We could update .*rc file corresponding to current shell (e.g. .zshrc for ZSH), but this way set of shells is hand-picked and seems fragile.
  • We could ask the user to update the variables, but it would defeat the purpose of one-line installation. I'd like to not do anything manually.

I'm not sure what's the proper way of doing such kind of thing, as updating user's .rc files feels like an intrusion into user's settings.

Then, man simply doesn't work with off-system manual files. It can be pointed to manuals using command line option. Then we either:

  • Add an alias which would supply necessary options to man, so that something like userman rustc would work. Feels awkward.
  • Ignore the issue and tell users to point their man to installation directory if they want Rust manuals.

Maybe I miss another option?

What's your opinion on whether user installation should be implemented? What are your preferences on different options outlined above?

You should check multirust. It does per user install, it handles PATH/LD_LIBRARY_PATH for you, and let's you easily switch between nightly versions, and in the future it will let you switch between the stable, beta and nightly channels.

Thanks for suggestion.

However, the question is about rustup.sh as it’s a default installation method for new users.

Updating variables like LD_LIBRARY_PATH is entirely unnecessary. Check my run-rust script.

Essentially, what I do is:

  1. Install Rust in /home/install/rust-nightly

  2. Add a sym-link /home/install/rustrust-nightly

  3. Install run-rust somewhere and tell it where rust is (/home/install/rust)

  4. Add sym-links to run-rust in my local bin directory:

    ~/.local/bin$ ls -l rust* cargo
    lrwxrwxrwx. 1 dhardy dhardy 8 Dec  1 11:46 cargo -> run-rust
    lrwxrwxrwx. 1 dhardy dhardy 8 Dec  1 11:46 rustc -> run-rust
    lrwxrwxrwx. 1 dhardy dhardy 8 Dec  1 11:46 rustdoc -> run-rust
    lrwxrwxrwx. 1 dhardy dhardy 8 Dec  1 11:46 rust-lldb -> run-rust

It is an option.

However, there still should be a local user directory addded to $PATH. If we're going to modify $PATH, we might as well just modify $LD_LIBRARY_PATH.

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