简体   繁体   中英

How to install Rails without using sudo gem install

I have installed rbenv using Homebrew.

$ rbenv local
2.4.0

$ rbenv global
2.4.0

$ ruby -v
ruby 2.4.0p0 (2016-12-24 revision 57164) [x86_64-darwin16]

When I check the Rails version I get the following message;

Rails is not currently installed on this system. To get the latest version, simply type:

$ sudo gem install rails

You can then rerun your "rails" command.

I have been told not to install Rails using sudo, so I have tried running gem install rails but it gives me the following error;

ERROR:  While executing gem ... (Errno::EACCES)
    Permission denied @ rb_sysopen -        /Users/USER1/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/thread_safe-0.3.6/.rspec

Is it correct that I should not install rails with sudo, and if so how can I?

I installed RVM (requires download and use of GPG) and followed the steps on RVM's install page. Should you use sudo? I've read both ways. Here is the page link:

https://rvm.io/rvm/install

The command once RVM is installed:

\curl -sSL https://get.rvm.io | bash -s stable --rails

That will install the latest stable version of rails available. I did this as a complete novice and it has worked for me (as a slightly higher novice) so far.

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