Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

macOS + zsh で /usr/local/rails を実行してしまう #32

Open
igaiga opened this issue Jul 14, 2019 · 0 comments
Open

macOS + zsh で /usr/local/rails を実行してしまう #32

igaiga opened this issue Jul 14, 2019 · 0 comments
Labels

Comments

@igaiga
Copy link

igaiga commented Jul 14, 2019

環境

macOS + zsh

問題発生時の状況

以下のエラーメッセージが出る

Rails is not currently installed on this system. To get the latest version, simply type:

    $ sudo gem install rails

You can then rerun your "rails" command.

原因

  • zshはコマンドパスをキャッシュしている
  • macOSは /usr/bin/rails にデフォルトでrailsをインストールしている
  • gem i rails する前にrailsコマンドを実行すると、(rbenvのrailsではなく) /usr/bin/rails を実行し、パスをキャッシュしてしまう
  • そのあとでrbenv のRubyでgem i railsしても、キャッシュで覚えた /usr/bin/rails を実行してしまう

解決方法

rbenv rehashのほかに、zshのrehashコマンドを実行する

  • $ rbenv rehash
  • $ rehash

注意点

  • しばらくはzshをインストールしている人はほぼいないと思うので問題はなさそう
  • macOS Catalina からzshがデフォルトshellになるので、問題が起きるかもしれない
@emorima emorima added the Mac label Sep 1, 2019
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants