gem installed but 'rails' commands don't work

霸气de小男生 提交于 2019-12-10 16:58:07

问题


when I run any rails command like rails s I get the following error:

Could not find diff-lcs-1.1.2 in any of the sources Try running bundle install.

However, I already installed diff-lcs.

bundle show diff-lcs /opt/local/lib/ruby1.9/gems/1.9.1/gems/diff-lcs-1.1.2

I also see diff-lcs when I do a gem list command

My GEM_HOME is /opt/local/lib/ruby1.9/gems/1.9.1

For reference, here's the contents of my Gemfile:

source 'http://rubygems.org'

gem 'rails', '3.0.0'
gem 'sqlite3-ruby', '1.2.5', :require => 'sqlite3'

group :development do
  gem 'rspec-rails', '2.0.0'
end

group :test do
  gem 'rspec', '2.0.0'
  gem 'webrat', '0.7.1'
end

And the output of which rails is /usr/bin/rails


回答1:


If you are using Rails 3, edit 'Gemfile' in the root of your rails app such that it contains

gem 'diff-lcs'

Then run 'bundle install' from the root of your rails app.




回答2:


Type "gem env" on your terminal. Check the executable path. Verify that it's set correctly.




回答3:


A bit late to the party, but I had the same problem (though with Apache and Phusion, but the solution could quite easily be the same). It turns out that though I set the GEM_PATH in my .bashrc, the server evidently doesn't get the bash environment. I fixed it following the advice here, in particular creating the config/setup_load_paths.rb file and adding the following line:

ENV['GEM_HOME']='/path/to/my/gems'



回答4:


Same problem.

Still haven't found an ideal solution, but if you delete the 'spring' gem from your gemfile, you should at least get things up and running again.



来源:https://stackoverflow.com/questions/3948130/gem-installed-but-rails-commands-dont-work

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!