Could not find RubyGem railties

2020-06-29 04:52发布

问题:

I try to create new app with "rails new" command however getting this error:

'report_activate_error': Could not find RubyGem railties (>= 0) (Gem::LoadError)
 from /usr/lib/ruby/vendor_ruby/1.8/rubygems.rb:244:in 'activate_dep'
 from /usr/lib/ruby/vendor_ruby/1.8/rubygems.rb:236:in `activate'
 from /usr/lib/ruby/vendor_ruby/1.8/rubygems.rb:1307:in `gem'
 from /usr/local/bin/rails:18

Any idea why?

by the way I am working on Ubuntu

gem list

*** LOCAL GEMS ***

it is empty but I installed rails just before

回答1:

I have encountered the issue before.The solution is : you must use comand gem install rails, not sudo gem install rails.



回答2:

I encountered the same problem and found the following solution Here which was mentioned here. Hope it helps

After you installed RVM and after you set the default Ruby version in RVM, you need to re-install all ruby gems, e.g.

gem install rails

you need to install those gems as the user, not as root.

Because from now on RVM will keep track of all installed gems by the ruby version which was used to install them!



回答3:

You need to install RVM (I don't know it is the best solution but it works) then use such rails commands like rvmsudo rails new or such. I use rails and ruby command with including rvm or rvmsudo phase and all of them start to work.



回答4:

Do you have multiple Ruby installations on your system? Maybe you have installed some package (like Heroku with full installation) and you are using the 'new' Ruby installation. I have uninstalled the last Ruby and everything seems to be fine.

Edit: Not everything is fine... yet. Under Windows you will have to edit Heroku.bat (in your Program Files/Heroku path) and change the path to Ruby installation folder.



回答5:

Install rvm and try it again to install rails RVM provides a very great way to manage your gems in Gemsets for multible ruby installations.

On the offizial rvm site is a installation tutorial

http://beginrescueend.com/