I have tried to install rails multiple times, but I keep getting this error. Also, whenever I update ruby to version 3.1 and set the global install to 3.1, I receive this message stating I am still on 2.6. I use MacOS and homebrew too.
ebirch@Ejs-MacBook-Pro ~ % sudo gem install rails
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/gems/2.6.0 directory.
Based on your brief context I am gonna assume you're not using a tool such as rbenv or RVM and am gonna recommend these.
I would recommend to go with a guide like this (instead of reading the above tools docs): https://www.digitalocean.com/community/tutorials/how-to-install-ruby-on-rails-with-rbenv-on-macos Basically until step 3 there is good enough and you just change the versions of ruby and rails to whatever you need.
Note (since I saw another answer mentioning conda): conda is also a more general (not specific to ruby) environment manager and if that works for you great too.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With