Safely source Cargo `env` file
Open
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:
- This leads to errors if the location is unavailable
- The line is added simultaneously to
~/.profile,~/.bashrcand~/.bash_profile.
Describe the solution you'd like
-
Test if the file can be accessed prior to sourcing it:
if [ -r "$HOME/.aliases.sh" ]; then source "$HOME/.aliases.sh"; fi -
Don't add in >1 place.
Notes
- Bonus points: test if Bash is the login shell indeed, maybe the Rust equivalent of:
getent passwd $USER | cut -d':' -f7
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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