rust-lang / rust-lang/rustup

Respecting the `CARGO_HOME` environment variable after `rustup` was installed

Open
#3,020 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
Rust
Stars
7k
Forks
1.1k
Avg merge
22h 40m
Merged PRs (30d)
46

Description

Problem you are trying to solve

I downloaded rustup via the command provided on the official website:

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

and then followed the on-screen instructions to install it. I then added
the CARGO_HOME environment variable to my shell initialization script (.zshrc in my case):

export CARGO_HOME="$HOME/.rust/cargo"

only to find out that the line added to .profile or .zshenv is already
using the default location for cargo:

. $HOME/.cargo/env

and also the env script was adding the default bin to my PATH:

export PATH="$HOME/.cargo/bin:$PATH"

and so my CARGO_HOME environment variable was effectively doing nothing.

Solution you'd like

I fixed the problem by modifying the line in my shell initialization script to
look like below:

. "$CARGO_HOME/env"

And also modified the $CARGO_HOME/env script:

export PATH="${CARGO_HOME}/bin:$PATH"

I think this would make a nice addition to the project: a cleaner
rustup install management.

Notes

Since this was a simple enough fix and I've been looking for a way to
start contributing to open-source projects, I thought this might be a
good first contribution for me. I searched through this repository
and the rustup-init.sh file so that I could maybe find the relevant lines
of code and fix them--with no success.

If possible, I would like a little bit of guidance on which files to edit
so that I can contribute this fix myself.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by inspecting rustup-init.sh and the shell initialization references mentioned in the issue, including .profile, .zshenv, and $CARGO_HOME/env. Trace how CARGO_HOME and PATH are written during installation, then verify that the generated setup uses the configured Cargo location rather than the default; the payload names no existing test to run.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust, shell
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.