Rails - rake:gems:install - 不安装 gem

发布于 2024-08-25 05:25:36 字数 449 浏览 5 评论 0原文

如果我在 config/environments/test.rb 文件中定义了一些 gem,如下所示:

config.gem "rspec"
config.gem "rspec-rails"
config.gem "mocha"

然后运行 ​​'rake gems:install RAILS_ENV=test'

我会收到以下错误:

Missing these required gems:
  mocha  

Run `rake gems:install` to install the missing gems.

但是,如果我运行 rake gems:install 就像它说的那样继续这样递归下去直到永远。

我如何实际使用 rake (而不是 gem install)来安装 gem?

谢谢!

If i define a few gems in my config/environments/test.rb file like this:

config.gem "rspec"
config.gem "rspec-rails"
config.gem "mocha"

and then run 'rake gems:install RAILS_ENV=test'

I get the following error:

Missing these required gems:
  mocha  

Run `rake gems:install` to install the missing gems.

however if I run rake gems:install like it says it will continue to recurse like this forever.

How do I actually get the gems to install using rake (not gem install)?

thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

后来的我们 2024-09-01 05:25:36

我想知道,您的 rake 文件或environment.rb 文件中是否引用了 mocha gem 中的某些内容?我以前见过类似的问题,并且它表现为此类问题。

尝试“手动”安装 mocha ...

gem install mocha

然后看看是否可以运行 rake gems:install

I wonder, is there a reference to something from the mocha gem in your rake file or environment.rb file? I've seen issues like this before and it presents as this type of problem.

Try installing mocha 'manually' with...

gem install mocha

Then see if you can run rake gems:install.

戒ㄋ 2024-09-01 05:25:36

我也遇到了这个问题,并按照此处的说明进行操作解决它。具体来说,删除并重新生成 lib/tasks/rspec.rake 非常重要。另外,添加

:lib => false

也有

config.gem "rspec", :lib => false, :version => ">= 1.2.0"

帮助。

I ran into this problem as well, and followed the directions here to resolve it. Specifically, deleting and regenerating lib/tasks/rspec.rake is pretty crucial. Also, adding

:lib => false

to

config.gem "rspec", :lib => false, :version => ">= 1.2.0"

helped.

星光不落少年眉 2024-09-01 05:25:36

我发现这是一个 GEM_PATH 问题。基本上,rails 无法找到您已安装的 gem,即使它们在那里,它们也是完全不可见的。有点奇怪,但是嘿。

在 dreamhost 上,我必须配置以下行:

ENV['GEM_PATH'] = '/home/<my_account>/.gems:/usr/lib/ruby/gems/1.8/gems'

在 config/environment.rb 中

,但在我的开发盒上,这对我不起作用,必须完全删除。
YMMV 但我建议这是一个开始寻找的好地方。

I found this was a GEM_PATH issue. Basically, rails can't find the gems you've installed and even though they're there, they're completely invisible. A bit weird, but hey.

On dreamhost I had to configure the line:

ENV['GEM_PATH'] = '/home/<my_account>/.gems:/usr/lib/ruby/gems/1.8/gems'

in config/environment.rb

but on my dev box this doesn't work for me and has to be removed entirely.
YMMV but I'd suggest that's a good place to start looking.

流殇 2024-09-01 05:25:36

您使用哪个平台?如果它是窗口,则

执行下面的命令及其工作

gem install mocha --platform=mswin32

Which platform are you using? If it it window then

Execute Below command and its works

gem install mocha --platform=mswin32

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文