これは何?
rustの環境構築していたら.zshrcや.bashrcの設定なしに$HOME/.cargo/bin/cargoや$HOME/.cargo/bin/rustcのPATHが通っていて気持ち悪かったので調査しました。
結論
rustup使用時に~/.profileに以下の設定が入ることがわかりました。
-
rustup install時に1を選択する
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh 1) Proceed with standard installation (default - just press enter) 2) Customize installation 3) Cancel installation -
~/.profileに以下が自動的に記載される。. "$HOME/.cargo/env" -
~/.profileはシェルにログイン時に読み込まれる -
~/.cargo/envがPATHを通している。#!/bin/sh # rustup shell setup # affix colons on either side of $PATH to simplify matching case ":${PATH}:" in *:"$HOME/.cargo/bin":*) ;; *) # Prepending path in case a system-installed rustc needs to be overridden export PATH="$HOME/.cargo/bin:$PATH" ;; esac