LoginSignup
0
0

More than 1 year has passed since last update.

direnv: error can't find bash: exec: "bash": executable file not found in $PATHエラーの解決方法

Posted at

どういう状況だったか

あらゆるコマンド(ls,ruby -v,rails s等)を押しても、command not foundになってしまっていた。

原因

vim ~/.bash_profileで、PATHの環境変数をいじって、source ~/.bash_profileで反映させた時、誤字が含まれてしまった。実際に、echo $PATHで確認してみると、以下のように表示された。
https://gyazo.com/fa12919337960c038255c183cb6c765b

解決方法

bash_profileの中身がおかしくなっていた時に、上記のエラーが出た。そして、vim ~/.bash_profileコマンドでは弾かれたので、ホームディレクトリで/usr/bin/vi .bash_profileコマンドを押すことによって、bash_profileの中身は確認できる。

以下は同じ意味

/usr/bin/vim .bash_profile 
vim ~/.bash_profile

bash_profileに誤字かスペースが入っていたため、エラーが起きているので、bash_profileを一度削除し、新しく作り直すことで解決できた。

①bash_profileの中身をメモする。

②bash_profileを削除する

rm .bash_profile

③bash_profileを作成する

touch ~/.bash_profile 

④先ほどメモした中身を手動で入力していく

また、ターミナルは再起動しないと反映されていなかったりする。

0
0
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
0
0