I'm getting this error when I'm trying to use Rails. It seems there are problems with using local files.

pasting below to show the versions of ruby and rails

~ $ ruby -v
ruby 2.4.2p198 (2017-09-14 revision 59899) [x86_64-darwin17]
~ $ rails -v
Rails 5.1.4

pasting the common error when trying to use rails or ruby

~ $ gem uninstall rails
ERROR:  While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /usr/local/lib/ruby/gems/2.4.0 directory.

2 Answers 2


By default /usr/local/lib is owned by root:wheel.

To install or uninstall gems you have to prepend sudo ....

There is no need to set up a new user, in particular because a new user won't change the permissions of the mentioned folder!

If you want to install gems with your current user without prepending sudo, change the permissions of the path /usr/local/lib/ruby/gems/ and make it $(whoami) r/w.


You could try a tool that creates a virtual environment. That would allow you to download just the tools you need - correct versions, etc, and it's self-contained. That way you don't need to worry about the system's versions of your dependencies, nor the other users on your system. Apparently RVM is the Ruby version of what I had in mind.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .