LoginSignup
3
3

More than 3 years have passed since last update.

Macでターミナルを再起動するとPATHを通したコマンドが使えなくなった

Last updated at Posted at 2020-03-14

自分の体験

  1. 開発でMacを使うことになり、環境構築をしていた。
  2. nvmをインストールし、下記のページ等を参考にし、~/.bash_profileにPATHを通すすための記述をした。 https://photo-tea.com/p/17/hexo-start-kit-tools-4/
  3. source ~/.bash_profileを実行 → nvmコマンドが使えるようになった。
  4. ターミナルを再起動すると再びnvmコマンドが使えなくなった(source ~/.bash_profileを実行すれば使えるという状態)。

解決方法

・下記コマンドの実行
ps -p $$
psコマンドは、Linux上で動作しているプロセスを確認するためのコマンド。
-pというオプションは、指定したプロセス番号を表示するためのオプション?らしい。
$$はログインしているシェルのプロセス番号?を指すらしい。
表示されたのが-bashではなく-zshであれば、.zshrcファイルを編集する必要がある。

・~/.bash_profileファイルにPATHを通すための記載をしてある場合は、下記コマンドを.zshrcファイルに記載するだけでok
source ~/.bash_profile

原因

使用しているMAcOSが"Catalina"の場合は、デフォルトシェルがzshになっているらしい。
https://news.mynavi.jp/article/osxhack-241/

参考

https://eng-entrance.com/linux-command-ps#-pp--pidPID
https://qiita.com/soarflat/items/d5015bec37f8a8254380
https://raccoonico.com/nodebrew-nvm-zshrc/
https://kamotora.net/system/aix/shell-doubledolloar-mark/
https://wa3.i-3-i.info/word11032.html

3
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
3