Ruby-on-rails “无法在任何来源中找到 *gem*”错误是否有修复,不涉及删除 Gemfile.lock?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11885398/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-03 03:50:21  来源:igfitidea点击:

Is there a fix for the "Could not find *gem* in any of the sources" error that doesn't involve deleting Gemfile.lock?

ruby-on-railsruby-on-rails-3

提问by ben

I am trying to get my development environment setup on a new computer.

我正在尝试在新计算机上设置我的开发环境。

git clone -o heroku [email protected]:theirapp.git
cd theirapp
bundle
Fetching gem metadata from https://rubygems.org/......
Fetching gem metadata from https://rubygems.org/..
Could not find jquery-rails-2.0.0 in any of the sources

After googling this error, the response seems to be to delete Gemfile.lock, then running bundleagain. This works, but then I have different versions of gems where I haven't specified a version in Gemfile. Is there a way to fix this error without deleting Gemfile.lock? I'm using Rails 3.2 and Ruby 1.9.3.

谷歌搜索此错误后,响应似乎是 delete Gemfile.lock,然后bundle再次运行。这有效,但是我有不同版本的 gems,我没有在Gemfile. 有没有办法在不删除的情况下修复这个错误Gemfile.lock?我使用的是 Rails 3.2 和 Ruby 1.9.3。

采纳答案by Hoa

According to rubygems.org, jquery-rails 2.0.0 has been yanked. That explains the error you had with jquery-rails.

据 ruby​​gems.org 称,jquery-rails 2.0.0 已被yanked。这解释了您使用 jquery-rails 时遇到的错误。

Running $ bundle update jquery-railswill rebuild your gem snapshot. That way you don't have to delete Gemfile.lock

运行$ bundle update jquery-rails将重建您的 gem 快照。这样你就不必删除 Gemfile.lock

回答by Jamie-505

simply run

简单地运行

bundle --full-index

that should do the trick

这应该够了吧

回答by Harlan T Wood

An old version of bundler was giving me this same issue. After a bunch of puzzling, I realized that this was the issue.

旧版本的 bundler 给了我同样的问题。经过一番折腾,我意识到这就是问题所在。

Running gem install bundlerfixed it completely.

运行gem install bundler完全修复它。

回答by pwightman

bundle update jquery-railswill update just the jquery-railsgem, which is likely what you're looking for. Running bundle updateis the equivalent of deleting Gemfile.lockand is not recommended in most cases. See here: Heroku push rejected: can't find jquery-rails-2.0.0 in sources

bundle update jquery-rails将只更新jquery-railsgem,这可能是您正在寻找的。运行bundle update相当于删除Gemfile.lock,在大多数情况下不推荐使用。请参阅此处:Heroku 推送被拒绝:在源中找不到 jquery-rails-2.0.0

回答by pixelearth

I've found it safest ALWAYS to specify gem versions, and only change them when necessary. Saved me a LOT of trouble.

我发现始终指定 gem 版本是最安全的,并且仅在必要时更改它们。为我省去了很多麻烦。