LoginSignup
1
0

More than 1 year has passed since last update.

rbenv global を出力してもversionが切り替わらない!

Last updated at Posted at 2021-11-26

背景

AWSへのデプロイ中に
EDITOR=vim bin/rails credentials:editをしたらversionが古いと言われたので

bundle install 

を実行すると

ERROR:  While executing gem ... (Gem::FilePermissionError)
    You don't have write permissions for the /Library/Ruby/Gems/2.3.0 directory.

訳: 許可がありません(ざっくり)
と言われました。

↑の記事を見ると、これが起こる原因はrbenvのversionがデフォルトのシステムを使っていて権限がないからエラーになると聞いたので、確かめてみるとシステムのversionを使っていました。

そこでGemfileに記載されているrubyのversion3.0.2をセットしようと

rbenv global 3.0.2

を実行したが、できず、rubyの参照先や実行パスを通してみたもののversionを切り替えることができなかった。

いきなり結論

rbenv local 3.0.2

と出力すると、すんなりversion切り替えができました。
rbenv globalとrbenv localの違いは、rbenvが開発する時のデフォルトのrubyのversionを指定するのがglobalであり、特定のディレクトリ下のみのrubyのversionを指定するのがlocalでした。覚えてないですが、おそらく以前にlocalでversionを指定しまったのでしょう…。

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