Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Ruby Installing a Ruby on Rails Development Environment in OS X

Brian Patterson
Brian Patterson
19,588 Points

Getting permissions error.

Getting this error when installing bundler and rails. Brian-Pattersons-iMac:~ briankaty1$ gem install bundler ERROR: While executing gem ... (Gem::FilePermissionError) You don't have write permissions for the /Library/Ruby/Gems/2.0.0 directory.

3 Answers

John O.
John O.
4,680 Points

Are you using a Ruby version manager like Rbenv or RVM?

Based on the error you are getting it looks like it is trying to install the bundler gem in the system included Ruby library.

If you want to continue adding the gem to the OS X system gems then you'll need to prefix the command with sudo

$sudo gem install bundler

If you don't want to install to you system, make sure that the Ruby version manager you want to use if working properly.

Here's a good guild for OS X: https://gorails.com/setup/osx/10.10-yosemite

Brian Patterson
Brian Patterson
19,588 Points

Brian-Pattersons-iMac:~ briankaty1$ sudo gem install bundler Password: Fetching: bundler-1.11.2.gem (100%) ERROR: While executing gem ... (Errno::EPERM) Operation not permitted - /usr/bin/bundle Brian-Pattersons-iMac:~ briankaty1$

Getting this error.

Brian Patterson
Brian Patterson
19,588 Points

Last login: Sun Jan 17 20:05:14 on ttys000 Brian-Pattersons-iMac:~ briankaty1$ $more ~/.bash_profile -bash: /Users/briankaty1/.bash_profile: No such file or directory Brian-Pattersons-iMac:~ briankaty1$ $rbenv versions -bash: versions: command not found Brian-Pattersons-iMac:~ briankaty1$ sudo more ~/.bash_profile Password: /Users/briankaty1/.bash_profile: No such file or directory Brian-Pattersons-iMac:~ briankaty1$ rbenv versions system 2.2.1

  • 2.2.3 (set by /Users/briankaty1/.rbenv/version) Brian-Pattersons-iMac:~ briankaty1$ which ruby /usr/bin/ruby Brian-Pattersons-iMac:~ briankaty1$ which gem /usr/bin/gem Brian-Pattersons-iMac:~ briankaty1$ more ~/.bash_profile /Users/briankaty1/.bash_profile: No such file or directory Brian-Pattersons-iMac:~ briankaty1$
Brian Patterson
Brian Patterson
19,588 Points

Having real issues trying to install the Ruby on Rails. Brian-Pattersons-iMac:~ briankaty1$ ln -s "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl" /usr/local/bin/sublime Brian-Pattersons-iMac:~ briankaty1$ gem install bundler ERROR: While executing gem ... (Gem::FilePermissionError) You don't have write permissions for the /Library/Ruby/Gems/2.0.0 directory. Brian-Pattersons-iMac:~ briankaty1$ rbenv rehash Brian-Pattersons-iMac:~ briankaty1$ ln -s "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl" /usr/local/bin/sublime ln: /usr/local/bin/sublime: File exists Brian-Pattersons-iMac:~ briankaty1$ sudo gem install bundler Password: Fetching: bundler-1.11.2.gem (100%) ERROR: While executing gem ... (Errno::EPERM) Operation not permitted - /usr/bin/bundle Brian-Pattersons-iMac:~ briankaty1$ rbenv rehash Brian-Pattersons-iMac:~ briankaty1$ sudo gem install rails Fetching: i18n-0.7.0.gem (100%) Successfully installed i18n-0.7.0 Fetching: minitest-5.8.3.gem (100%) Successfully installed minitest-5.8.3 Fetching: thread_safe-0.3.5.gem (100%) Successfully installed thread_safe-0.3.5 Fetching: tzinfo-1.2.2.gem (100%) Successfully installed tzinfo-1.2.2 Fetching: activesupport-4.2.5.gem (100%) Successfully installed activesupport-4.2.5 Fetching: builder-3.2.2.gem (100%) Successfully installed builder-3.2.2 Fetching: erubis-2.7.0.gem (100%) ERROR: While executing gem ... (Errno::EPERM) Operation not permitted - /usr/bin/erubis Brian-Pattersons-iMac:~ briankaty1$ gem install rails -v 4.2.4 Fetching: activesupport-4.2.4.gem (100%) ERROR: While executing gem ... (Gem::FilePermissionError) You don't have write permissions for the /Library/Ruby/Gems/2.0.0 directory.

John O.
John O.
4,680 Points

Could you try the following and post the results?

  1. Check you .bash_profile
$more ~/.bash_profile
  1. See what versions of Ruby you have on your system
$rbenv versions
  1. See with Ruby you are using
$which ruby
$which gem

If you can post the results of the above I might have a better idea of what's going on with your setup.

Brian Patterson
Brian Patterson
19,588 Points

<p>Last login: Sun Jan 17 20:05:14 on ttys000 Brian-Pattersons-iMac:~ briankaty1$ $more ~/.bash_profile -bash: /Users/briankaty1/.bash_profile: No such file or directory Brian-Pattersons-iMac:~ briankaty1$ $rbenv versions -bash: versions: command not found Brian-Pattersons-iMac:~ briankaty1$ sudo more ~/.bash_profile Password: /Users/briankaty1/.bash_profile: No such file or directory Brian-Pattersons-iMac:~ briankaty1$ rbenv versions system 2.2.1

  • 2.2.3 (set by /Users/briankaty1/.rbenv/version) Brian-Pattersons-iMac:~ briankaty1$ which ruby /usr/bin/ruby Brian-Pattersons-iMac:~ briankaty1$ which gem /usr/bin/gem Brian-Pattersons-iMac:~ briankaty1$ more ~/.bash_profile /Users/briankaty1/.bash_profile: No such file or directory Brian-Pattersons-iMac:~ briankaty1$ </p>
John O.
John O.
4,680 Points

From you terminal run the following to create and add the necessary rbenv setup to your environment:

$echo 'if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi' >> ~/.bash_profile

Close your terminal and reopen it then run the following:

$rbenv global 2.2.3
$rbenv rehash

This will set your global Ruby to your rbenv install 2.2.3 version. If this worked then you should be able to gem install bundler with:

$gem install bundler