Have you tried to install a Ruby gem (like Rails, Jekyll, or cocoapods) and received a write permissions error? This is one of the most prevalent mistakes made by humans. If you try to install a gem on a Mac that hasn't been properly configured for Ruby development, you'll see this error.
Photo by Gaming_birder
Table of Content:
1 - Explanation of You Don't Have Write Permissions For the /library/ruby/gems/2.3.0 Directory
2 - Reasons for the Appearance of This Message
3 - The Solution
4 - The Conclusion
Explanation of You Don't Have Write Permissions For the /library/ruby/gems/2.3.0 Directory
If you've installed a Ruby via Homebrew and you go to do a gem install, you might see this error:gem install fyber-ruby-sdk -v '1.1.0'ERROR: While executing gem ... (Gem::FilePermissionError)You don't have write permissions into the /Library/Ruby/Gems/2.3.0 directory.
You don't have write permissions for the /library/ruby/gems/2.3.0 directory. This is a common error message when trying to install gems on a MacOS X system, and it can be frustrating to deal with if you don't know what's happening.
Reasons for the Appearance of This Message
A person can make a mistake during any task, It is not required for the error to be discovered right away. thanks to the computer which immediately identifies any mistake and notifies its user immediately. It is important to discuss the reasons for the mistake we are discussing. the reason to see this message you don't have write permissions for the /library/ruby/gems/2.3.0 directory is certain versions of Ruby, such as those found on macOS and Ubuntu, require elevated rights to install gems. When installing a gem without writing permissions this error message will appear.
The Solution
So, how do you install gems on a Mac the right way? The most reliable technique, and the only one I advocate, is to use a version manager to install a separate and newer version of Ruby. I strongly advise you to use Ruby version management since it allows you to install many versions of Ruby at the same time and makes switching between them a breeze. Even if you're new to Ruby, it's worth your time to learn how to use a Ruby manager since you'll need one eventually.
A functioning Ruby environment on macOS with a Ruby manager may be achieved in a minimum of five steps:
Homebrew should be installed (which will also install the prerequisite Apple command-line tools)
Use a Ruby version manager like chruby or ruby-install to manage your Ruby versions (others include rbenv, asdf, and RVM)
Set up Ruby's version management.
Install a certain Ruby version.
Change to that Ruby version.
It isn't limited to a single application. You may run it as often as you like to maintain your system secure and up to date. It can also save you half a day the next time you obtain a new Mac by automatically installing all of your Mac software as well as a complete development environment. For a one-time fee, you can benefit from all of these time savings now and in the future.
The Conclusion
This is the most common reason for you not being able to install a gem. If you ever see this error message, double-check your permissions and try again!
Top comments (0)