-
Notifications
You must be signed in to change notification settings - Fork 893
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Document of "How to Install Rust Environment for Multiple Users on Linux?" #2383
Comments
I think you will find that both cargo and rustup are unsafe for this use case, and that actually large companies don't have the strict requirement you are saying they do have (I say this having worked in the office of the CTO of a 300000 person company and in a different business unit of a 50000 person company). Rustup is not safe for concurrent use (see #988) and when used concurrently will corrupt it's working area (see #2417). Cargo uses locks for safety, but these will not scale to large numbers of users, because they are not RW locks, they are mutexes. Fundamental redesigns are needed to enable your proposed use case in a direct fashion. I think a much better fashion of supporting it is to make installing the company agreed version very reliable and straight forward, so that every developer can have it easily, regardless of their operating system, and if they need to build a custom compiler to test a bug fix - they can do that, and if they need to test nightly to test a bugfix - they can do that. If your company has a policy that says you must have a specific locked down version and developers cannot change their tooling at all - well, I have two recommendations for you:
I'm going to close this bug, because we cannot add such a document, because it is not possible today, if ever. We can revisit this if in future rustup is robust against the stresses such an environment would bring. |
In case anyone is looking for a macOS solution, the following script installs |
Here's a blog post on installing Rust globally on linux. |
Setting CARGO_HOME to /usr/local/* is a very bad idea. The goal of installing anything global is to share resources among users of a system, however Cargo uses Cargo home for many things such as caching and what not. This would lead to file locks if several users were compiling. You should take a look at the macOS script and adapt it to Linux. I could also post my Linux one if desired. |
@jun-sheaf , I'm new to rust, please post one for ref, thanks. |
So basically rust will surely crash if there are a lot of users compiling stuff using shared libraries system wide? |
Describe the problem you are trying to solve
For research and development team of lots of companies, they need a consistent Rust development environment for all of their team members, and generally the IT department or one team member help to install and maintain the development tools, so they want know how to install Rust development environment for all of their team members.
Their detailed goals and requirements can be listed below:
Even through issues #1085 and #313 is relevant to this problem, but none of them are exactly focus on this problem and none of them give out the solution of this problem, so I create this new issue and give out my solution.
Describe the solution you'd like
I'd like there is a document to tell the peoples who have the same requirement the current available solution.
The current available solution
This solution is inspired by nodakai's answer of issue #1085 (comment), thanks.
All of operations of this solution only need to be done by one team member or IT department, and then all of other team members can start Rust development work without doing anything.
Install Rust Environment
Installation
Here we assume you want install
rustup
into directory/nfs/rust/rustup
andcargo
into directory/nfs/rust/cargo
.$ curl https://sh.rustup.rs -sSf | sudo env RUSTUP_HOME=/nfs/rust/rustup CARGO_HOME=/nfs/rust/cargo sh -s -- --default-toolchain stable --profile default --no-modify-path -y
Configuration
On Linux lots of environment setting is done by shell rc file, generally team will maintain a common shell rc file to do some settings that commonly used by all of the team members, and the new team member only need
source
the common shell rc file in his/her shell rc file then he/she can work.Here we assume your team has such common shell rc file, if not then you need tell all of your team members to do this step by themselves.
Add below content into the common shell rc file.
Now all of the team members already can do Rust development work, the key of here is not explicitly set
CARGO_HOME
, so each team member will implicitly use~/.cargo
as his/herCARGO_HOME
, that means when he/she usecargo run
the cache and crates will store under his/her home directory.Maintain Rust Environment
For example, the maintainer can use below command to install
nightly
toolchain and use it as default toolchain.The key of here is explicitly set
CARGO_HOME
to the installation directory/nfs/rust/cargo
, sorustup
can do the job correctly.System-wide Cargo
config
For some team, maybe sometime need do some system-wide configuration of
cargo
, e.g., replacecrates.io
with a faster mirror, we know this requirement can be implemented by settingconfig
file ofcargo
, generally these kind of settings are useful for all projects and all members of a team, so we want these kind of settings be configured in system-wideconfig
.We all know that now
cargo
hasn't a system-wideconfig
, below content is referenced fromThe Cargo Book
, we can find the file "/.cargo/config" is the most similar one to system-wideconfig
.You can store the
config
file insidecargo
installation directory/nfs/rust/cargo/
and make symbolic link/.cargo/config
to it on each machine.Notes
The text was updated successfully, but these errors were encountered: