Why do I get a permission error installing Ruby 1.9.3 with RVM?

  • Questioner

    I need to install a newer version of Ruby than 1.8.7.

    I already managed to install Homebrew and RVM, but this is what happens when I try to install Ruby.

    aldaman:~ Alex$ rvm install 1.9.3
    mkdir: /usr/local/rvm/log/ruby-1.9.3-p429: Permission denied
    mkdir: /usr/local/rvm/log/ruby-1.9.3-p429: Permission denied
    Searching for binary rubies, this might take some time.
    No binary rubies available for: osx/10.8/x86_64/ruby-1.9.3-p429.
    Continuing with compilation. Please read 'rvm mount' to get more information on binary rubies.
    Installing requirements for osx, might require sudo password.
    Already up-to-date.
    mkdir: /usr/local/rvm/log/ruby-1.9.3-p429: Permission denied
    tee: /usr/local/rvm/log/ruby-1.9.3-p429/1370998530_package_install_openssl.log: No such file or directory
    tee: /usr/local/rvm/log/ruby-1.9.3-p429/1370998530_package_install_openssl.log: No such file or directory
    Installing required packages: openssl.............................
    Error running 'requirements_osx_brew_libs_install openssl',
    please read /usr/local/rvm/log/ruby-1.9.3-p429/1370998530_package_install_openssl.log

    I have no idea how to fix it. Does someone know how?

  • Answers
  • Linuxios

    Try running with sudo:

    sudo rvm install 1.9.3
  • Elmatou

    It seems you installed rvm in 'Multi-user' mode aka 'system wide installation'.

    You should follow the instruction and add your user to 'rvm' group and reopen a session. Once this is done you will be able to install any rubies directly rvmsudo rvm install 1.9.3

    As often we should be careful on when to use a root account or a sudo invocation. As told in the rvm installation guide there no case where to use sudo only case with rvmsudo.

  • Related Question

    osx snow leopard - Ruby RubyGems: Why do I always get error messages when trying to install gems?
  • Andrew

    So I always seem to get error messages when I'm installing new gems. I'm new to Ruby, Rails, and RubyGems so it makes it very frustrating. I'm not sure if I need to configure something, or if I installed something incorrectly...So hopefully you can help. Here are some examples of the problems that I am having:

    #1: sudo vs. not using sudo

    In tons of tutorials/documentation they always use:

    gem install gem-name

    For me, this almost always results in some sort of error...until I do...

    sudo gem install gem-name

    ...then the gem usually installs fine. How is it that people are able to run gem install without starting with sudo?


    Install Ruby Version Manager!

    Seriously! I wish I would have done this sooner. Ruby Version Manager makes it possible to run multiple versions of Ruby, each with their own set of gems, and switch between the different versions seemlessly. Plus, you won't have to use sudo anymore. Plus, it's super easy to install, so you should do it!

    #2: "Can't find header files"

    Sometimes I get a message like this, even when running under sudo...

    /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb
    mkmf.rb can't find header files for ruby at /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/ruby.h

    What does that even mean?


    The problem is that it can't find the make command. It's installed automatically when you install XCode. And for some reason, even though I had XCode installed, it couldn't find it. I downloaded the latest version of XCode and reinstalled. Now when I run which make it correctly returns /usr/bin/make.

    Using Lion with the new version of Xcode, download ‘Command Line Tools for Xcode’ from https://developer.apple.com/downloads.

    #3: "Insecure world writable dir"

    Here's a new one.

    /Library/Ruby/Gems/1.8/gems/bundler-0.9.26/lib/bundler/source.rb:352: warning: Insecure world writable dir /usr/local/bin in PATH, mode 040777

    That doesn't look good. What do I need to do to fix it?


    Something I installed, at some point in time, changed the permissions on my /usr/local/bin directory (as well as my /usr/local and /usr/local/mysql directories). To change these back:

    sudo chmod 755 /usr/local/bin

    #4: Can't install bcrypt-ruby

    Finally, I am trying to run bundle install on my brand new Rails 3.0.0.beta4 app and I'm getting this error:

    Installing bcrypt-ruby (2.1.2) from .gem files at /Users/andrew/.bundle/ruby/1.8/cache with native extensions /Library/Ruby/Site/1.8/rubygems/installer.rb:483:in `build_extensions': ERROR: Failed to build gem native extension. (Gem::Installer::ExtensionBuildError)
    /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb
    mkmf.rb can't find header files for ruby at /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/ruby.h
    Gem files will remain installed in /Users/andrew/.bundle/ruby/1.8/gems/bcrypt-ruby-2.1.2 for inspection.
    Results logged to /Users/andrew/.bundle/ruby/1.8/gems/bcrypt-ruby-2.1.2/ext/mri/gem_make.out
        from /Library/Ruby/Site/1.8/rubygems/installer.rb:446:in `each'
        from /Library/Ruby/Site/1.8/rubygems/installer.rb:446:in `build_extensions'
        from /Library/Ruby/Site/1.8/rubygems/installer.rb:198:in `install'
        from /Library/Ruby/Gems/1.8/gems/bundler-0.9.26/lib/bundler/source.rb:170:in `install'
        from /Library/Ruby/Gems/1.8/gems/bundler-0.9.26/lib/bundler/installer.rb:34:in `run'
        from /Library/Ruby/Gems/1.8/gems/bundler-0.9.26/lib/bundler/spec_set.rb:12:in `each'
        from /Library/Ruby/Gems/1.8/gems/bundler-0.9.26/lib/bundler/spec_set.rb:12:in `each'
        from /Library/Ruby/Gems/1.8/gems/bundler-0.9.26/lib/bundler/installer.rb:21:in `run'
        from /Library/Ruby/Gems/1.8/gems/bundler-0.9.26/lib/bundler/installer.rb:6:in `install'
        from /Library/Ruby/Gems/1.8/gems/bundler-0.9.26/lib/bundler/cli.rb:91:in `install'
        from /Library/Ruby/Gems/1.8/gems/bundler-0.9.26/lib/bundler/vendor/thor/task.rb:33:in `send'
        from /Library/Ruby/Gems/1.8/gems/bundler-0.9.26/lib/bundler/vendor/thor/task.rb:33:in `run'
        from /Library/Ruby/Gems/1.8/gems/bundler-0.9.26/lib/bundler/vendor/thor/invocation.rb:109:in `invoke'
        from /Library/Ruby/Gems/1.8/gems/bundler-0.9.26/lib/bundler/vendor/thor/invocation.rb:116:in `call'
        from /Library/Ruby/Gems/1.8/gems/bundler-0.9.26/lib/bundler/vendor/thor/invocation.rb:116:in `invoke'
        from /Library/Ruby/Gems/1.8/gems/bundler-0.9.26/lib/bundler/vendor/thor.rb:137:in `start'
        from /Library/Ruby/Gems/1.8/gems/bundler-0.9.26/lib/bundler/vendor/thor/base.rb:378:in `start'
        from /Library/Ruby/Gems/1.8/gems/bundler-0.9.26/lib/bundler/vendor/thor.rb:124:in `start'
        from /Library/Ruby/Gems/1.8/gems/bundler-0.9.26/bin/bundle:13
        from /usr/bin/bundle:19:in `load'
        from /usr/bin/bundle:19

    It looks like bcrypt-ruby is some sort of dependency that it's trying to install. So how do I get that to work? How can I know the reason that it is failing?


    This was fixed by reinstalling XCode.

    Sorry for the laundry list, but I really want to get rid of all these issues!

    Thanks in advance!

  • Related Answers
  • slhck

    This would be better as separate questions as I can only answer some.

    1. sudo - On OS X, gems are installed in a directory under /Library. Anything here is shared by all users on the Mac and so to be able to write to it you need root access which is what sudo gives you.
      You see commands without the sudo when either people are explaining things quickly as they expect people to know when to use sudo or if they have setup ruby to install in a user directory as per Ruby documentation

    2. and 4.: Can't find header files for ruby.
      I suspect that you have not installed XCode, the Apple developer tools. They are on your OS X DVD or can be downloaded from Apple or the App Store if you are using OS X Lion.

    3. /usr/local/bin - that is bad.
      Run /Applications/Utilities/Disk Utility.app, choose the boot drive and repair permissions.

  • ghoppe

    I suggest installing Ruby Version Manger, and you don't have to worry about sudo issues, and can switch easily between different ruby versions and gem sets.

  • slhck

    Re #4:

    If you are missing XCode and have an Apple Developers account, you can also install only the Command Line Tools (about 180MB) - a download available on the ADC site.

  • Mohammed Arif

    The reason of the permission error is because you are not logged in as the root user on terminal.

    If you already have root use enable on your mac in terminal type (without the $)

    $ su

    If you dont have root user, you need to enable it using the following steps

    1. From the Apple menu choose System Preferences….
    2. From the View menu choose Users & Groups.
    3. Click the lock and authenticate as an administrator account.
    4. Click Login Options….
    5. Click the “Edit…” or “Join…” button at the bottom right.
    6. Click the “Open Directory Utility…” button.
    7. Click the lock in the Directory Utility window.
    8. Enter an administrator account name and password, then click OK.
    9. Choose Enable Root User from the Edit menu.
    10. Enter the root password you wish to use in both the Password and Verify fields, then click OK.

    More at the same on http://support.apple.com/kb/ht1528

    Atleast it works for me after getting stuck for couple of hours.