简体   繁体   中英

Permission denied , installing rails

I am trying to install rails , in order to install cocoapods but I am having some trouble with permissions. I tried $ $sudo chown -R username /usr/ but operation is now allowed.

Username-MacBook-Pro:~ username$ $sudo gem install rails
Building native extensions.  This could take a while...
ERROR:  While executing gem ... (Errno::EACCES)
    Permission denied @ dir_s_mkdir - /usr/local/lib/ruby/gems/2.2.0/extensions/x86_64-darwin-14
Username-MacBook-Pro:~ username$ 

You should not install rails with the sudo command for two reasons:

  1. I made this mistake in the past and then I had issues when installing and using other gems because of inconsistencies with permissions. It might very likely cause you the same trouble.
  2. The concern of whether or not to install rails with the sudo command is addressed and well explained in a different post: 'sudo gem install' or 'gem install' and gem locations

    The reason why installing gems with sudo is worse than just gem install is because it installs the gems for ALL USERS as root. This might be fine if you're the only person using the machine, but if you're not it can cause weirdness.

I recommend that you install rvm first and then rails. Here is a great tutorial that walks you through the process: http://railsapps.github.io/installrubyonrails-mac.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM