How do I fix the “You don't have write permissions into the /usr/bin directory” error when installing Rails?

后端 未结 9 1769
滥情空心
滥情空心 2020-12-07 07:56

I\'m trying to install Rails 3 on a brand new MacBook Pro running OS X 10.6.3, Ruby 1.8.7, and Rails 2.3.5 and I\'m wondering if I\'ve hosed myself. So far, I\'ve run these

相关标签:
9条回答
  • 2020-12-07 08:15

    To fix your specific error you need to run that command as sudo, ie:

    sudo gem install rails --pre
    
    0 讨论(0)
  • 2020-12-07 08:16

    I'd suggest using RVM it allows you have multiple versions of Ruby/Rails installed with gem profiles and basically keep all your gems contained from one another. You may want to check out a similar post How can I install Ruby on Rails 3 on OSX

    0 讨论(0)
  • 2020-12-07 08:27

    Using the -n /usr/local/bin flag does work, BUT I had to come back to this page every time I wanted to update a package again. So I figured out a permanent fix for this.

    For those interested in fixing this permanently:

    Create a ~/.gemrc file

    vim .gemrc
    

    With the following content:

    :gemdir:
       - ~/.gem/ruby
    install: -n /usr/local/bin
    

    Now you can run your command normally without the -n flag.

    Enjoy!

    0 讨论(0)
提交回复
热议问题