[英]gem installed but 'rails' commands don't work
when I run any rails command like rails s
I get the following error: 当我运行任何rails命令如
rails s
我收到以下错误:
Could not find diff-lcs-1.1.2 in any of the sources Try running bundle install
. 在任何源代码中找不到diff-lcs-1.1.2尝试运行
bundle install
。
However, I already installed diff-lcs. 但是,我已经安装了diff-lcs。
bundle show diff-lcs /opt/local/lib/ruby1.9/gems/1.9.1/gems/diff-lcs-1.1.2
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 当我执行
gem list
命令时,我也会看到diff-lcs
My GEM_HOME is /opt/local/lib/ruby1.9/gems/1.9.1 我的GEM_HOME是/opt/local/lib/ruby1.9/gems/1.9.1
For reference, here's the contents of my Gemfile: 作为参考,这是我的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
并且
which rails
的输出是/usr/bin/rails
If you are using Rails 3, edit 'Gemfile' in the root of your rails app such that it contains 如果您使用的是Rails 3,请在rails应用程序的根目录中编辑“Gemfile”,使其包含
gem 'diff-lcs'
Then run 'bundle install' from the root of your rails app. 然后从rails应用程序的根目录运行“bundle install”。
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). 派对有点晚了,但我遇到了同样的问题(虽然使用Apache和Phusion,但解决方案很容易相同)。 It turns out that though I set the
GEM_PATH
in my .bashrc, the server evidently doesn't get the bash environment. 事实证明,虽然我在.bashrc中设置了
GEM_PATH
,但服务器显然没有得到bash环境。 I fixed it following the advice here , in particular creating the config/setup_load_paths.rb
file and adding the following line: 我按照这里的建议修复了它,特别是创建了
config/setup_load_paths.rb
文件并添加了以下行:
ENV['GEM_HOME']='/path/to/my/gems'
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. 仍然没有找到理想的解决方案,但是如果你从gemfile中删除'spring'gem,你至少应该重新开始运行。
Type "gem env" on your terminal. 在终端上输入“gem env”。 Check the executable path.
检查可执行文件路径。 Verify that it's set correctly.
验证它是否设置正确。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.