简体   繁体   English

gem安装但'rails'命令不起作用

[英]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.

相关问题 传统的rails命令不适用于ruby 2.3 - traditional rails commands don't work with ruby 2.3 Rails:命令在format.json {…}内部不起作用 - Rails: Commands don't work inside format.json { … } 如何删除gem,这样我就不需要在rails命令前添加bundle exec? - How to delete a gem so that I don't need to prepend bundle exec for rails commands? 脚本/控制台不起作用; 报告“缺少Rails宝石。 即使rails显示为已安装,也请`gem install -v = rails ......” - script/console won't work; reports “Missing the Rails gem. Please `gem install -v= rails`…” even though rails shows as installed 使用websocket_rails gem的Rails应用中的方法broadcast_message不起作用 - Method broadcast_message in a rails app with websocket_rails gem don't work Rails找不到已安装的gem - Rails can't find installed gem Rails Gem会安装但不安装命令(软件包?)-Rubber Gem - Rails Gem installs but doesn't install commands (package?) - Rubber Gem 为什么RSpec的方法,“获取”,“发布”,“放置”,“删除”工作在gem(或Rails外部)的控制器规范中? - Why don't RSpec's methods, “get”, “post”, “put”, “delete” work in a controller spec in a gem (or outside Rails)? 拆分gem仪表板操作不起作用 - Split gem dashboard actions don't work ahoy_meta宝石不起作用 - ahoy_meta gem don't work
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM