rust-lang / rust-lang/rustup

Safely source Cargo `env` file

Open
#2,840 10 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Describe the problem you are trying to solve
rustup adds unconditional attempt to source $HOME/.cargo/env. Two problems:

  1. This leads to errors if the location is unavailable
  2. The line is added simultaneously to ~/.profile, ~/.bashrc and ~/.bash_profile.

Describe the solution you'd like

  1. Test if the file can be accessed prior to sourcing it:

    if [ -r "$HOME/.aliases.sh" ]; then source "$HOME/.aliases.sh"; fi
    
  2. Don't add in >1 place.

Notes

  1. Bonus points: test if Bash is the login shell indeed, maybe the Rust equivalent of:
    getent passwd $USER | cut -d':' -f7
    

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

Search the rustup source for the code that adds $HOME/.cargo/env to .profile, .bashrc, and .bash_profile; read the surrounding shell-initialization logic first. Reproduce the unavailable-file case and verify that only readable files are sourced and duplicate profile entries are avoided, with login-shell detection treated as the stated bonus.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.