Can't install Rails on Mac---don't have write permissions


#1

I am on the lesson “Your first Rails applications.” When I type in “gem install rails” into Terminal on my Mac, I get the following error:

Fetching: concurrent-ruby-1.0.5.gem (100%)
ERROR: While executing gem … (Gem::FilePermissionError)
You don’t have write permissions for the /Library/Ruby/Gems/2.3.0 directory.

(I already have some kind of installation of Ruby, I don’t know about rails though). When I Google this error, the suggested solutions tell me to use Environment Managers. But I want to figure out how to install Rails, The Odin Project way.


#2

Can I just type in “sudo gem install rails”? Or does that run the risk of messing something up?

[I tried typing in “rails” and it said it wasn’t installed…and suggested typing in the above command].


#3

Hi @wkdewey

It sounds like you’ve installed Ruby using sudo which you shouldn’t be doing. Can you link to which instructions you are following please?


#4

I believe I followed the instructions here: https://github.com/appacademy/dotfiles


#5

I followed their instructions at https://github.com/appacademy/dotfiles/blob/master/troubleshooting.md, to type in sudo chown -R “$USER” ~/.rbenv and that solved the problem. Rails is now installing.