简体   繁体   中英

Permission issues since upgrading to Ruby 2 and Rails 4 on OSX

I recently upgraded to Ruby 2 and Rails 4

$ ruby -v
ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-darwin12.4.0]

$ rails -v
Rails 4.0.0

Now, when I create a new rails app, when the bundle install part happens, I get asked for my system password, which never used to happen before. It also takes forever. Reference screenshot: http://i.imgur.com/6kh4g63.png

Secondly, whenever a gem shows up in my Gemfile which I don't already have, it requires installation. In this case, I flat out get a permission denied error. Reference screenshot: http://i.imgur.com/rcIq5Vq.png

Also, when I want to run "rake db:migrate", I have to run it with sudo now, whereas previously this wasn't the case. If I do sudo bundle install, then even my Gem installation problem gets fixed.

However, this is not how my workflow used to be, and I want to figure out why this is suddenly the case. Even my rails server which I previously could start by simply typing "rails s" now requires me to type "sudo rails s".

Does anyone know what is causing this and how I can fix it?

Thank you.

Okay, so I think I've solved it. Not sure if this is good practice or not, but it worked, so I thought I'd answer it:

First, I found out where my rails is located, by typing: "which rails"
It gave me: /usr/local/rvm/gems/ruby-2.0.0-p247/bin/rails

So I went to that folder: cd /usr/local/rvm/gems/ruby-2.0.0-p247/bin
I saw that everything was owned by root. So I changed that to my username:
sudo chown -R Myname *

I did the same for ruby: "which ruby"
cd /usr/local/rvm/rubies/ruby-2.0.0-p247/bin
sudo chown -R Myname *

I thought this would work, but when a new gem would install, the folder it would try to copy in would not have write permissions for my username. This folder was: /usr/local/rvm/gems/ruby-2.0.0-p247/build_info/

So I did: cd /usr/local/rvm/gems/ruby-2.0.0-p247
And then owned the folder: sudo chown -R Myname build_info

And voila, everything is working now.

Please correct me if this is bad practice or unsafe.

Thank you.

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