The VS Code Rust plugin assumes RUSTUP_HOME
and CARGO_HOME
are their default values, which presented a problem for me as I had them installed under /opt
. To get around this I added a quick shim script that defines those variables before exec
ing the real executables. Then I created symlinks with the name of each tool pointing to my shim in an location in PATH
. In other words, /usr/local/bin
looks like this:
/usr/local/bin/
├── cargo -> rustup-shim
├── cargo-clippy -> rustup-shim
├── cargo-fmt -> rustup-shim
├── cargo-miri -> rustup-shim
├── clippy-driver -> rustup-shim
├── rls -> rustup-shim
├── rustc -> rustup-shim
├── rustdoc -> rustup-shim
├── rustfmt -> rustup-shim
├── rust-gdb -> rustup-shim
├── rust-lldb -> rustup-shim
├── rustup -> rustup-shim
└── rustup-shim
Just edit the script below with your values of RUSTUP_HOME
and CARGO_HOME
. A one-liner to create the symlinks would look like:
for F in ${CARGO_HOME}/bin/*; do sudo ln -s rustup-shim /usr/local/bin/$(basename $F); done