3
2

More than 1 year has passed since last update.

An error occurred while installing racc (1.5.2), and Bundler cannot continue. / You don't have write permissions for the /Library/Ruby/Gems/2.6.0 directory.

Last updated at Posted at 2021-05-23

問題

rails newしたさいに以下のエラー

An error occurred while installing racc (1.5.2), and Bundler cannot continue.

以下を実行してみる

gem install racc -v '1.5.2' --source 'https://rubygems.org/'

なんか権限系のエラーがでた :thinking:

You don't have write permissions for the /Library/Ruby/Gems/2.6.0 directory.

いろいろ調べてたら、rbenvでインストールしたrubyではなく、systemのrubyを使っていると出たりするらしい。
systemのrubyを使ってる場合はwhich rubyと実行すると、/usr/bin/rubyとかえるそうだ。
ただ自分の場合、/Users/ユーザ名/.rbenv/shims/rubyとかえることから、すでにrbenvでrubyを管理していた。うーむ謎 :thinking:

解決策

結論、rbenvでrubyを管理してたけど、指定しているrubyがsystemのものになっているという状態だった。

rbenv versions
* system (set by /Users/ユーザ名/.rbenv/version)
  2.5.3
  2.5.8
  2.6.6
  2.7.1

なので、rbenvでインストールしたrubyを選択しましょう!

rbenv local 2.7.1

これでgemインストールできない問題も解決しました。

3
2
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
2