【问题标题】:Why does Bundler report "Could not find capistrano-2.11.1 in any of the sources"?为什么 Bundler 报告“在任何来源中都找不到 capistrano-2.11.1”?
【发布时间】:2012-05-09 11:03:16
【问题描述】:

捆绑器版本 1.0.22

部署到 RedHat Linux 6

Ruby 1.9.3p0

Rails 3.2.1


我阅读了 Bundler 文档并采取了这些步骤...

  • 在开发工作站上设置好所有东西,所以所有的 gem 都安装好了,应用程序可以工作并且测试通过了。

  • 已将 GemfileGemfile.lock 签入源代码管理。确保不要将.bundle 签入源代码管理。

我跑了$ cap deploy。现在我的代码在生产服务器上。

按照docs 中的说明,我登录,cd 到我的应用程序根目录,然后运行...

$ bundle install --development

这是结果...

$ bundle install --deployment
Fetching source index for https://rubygems.org/
Could not find capistrano-2.11.1 in any of the sources

有人知道为什么会出现这个错误吗?

知道如何说服 Bundler 安装所需的 gem?

我试图从 Bundler 认为的 gem 环境中找到线索...

$ bundle exec gem environment
Could not find rake-0.9.2.2 in any of the sources

我查看了 Bundler 故障排除页面并按照那里的说明删除了一堆东西...

# remove user-specific gems and git repos
rm -rf ~/.bundle/ ~/.gem/

# remove system-wide git repos and git checkouts
rm -rf $GEM_HOME/bundler/ $GEM_HOME/cache/bundler/

# remove project-specific settings and git repos
rm -rf .bundle/

# remove project-specific cached .gem files
rm -rf vendor/cache/

# remove the saved resolve of the Gemfile
#
# For now, did not delete this. If I understand the Bundler docs correctly,
# this file is sort of the whole point of Bundler. If I delete it, my deployed
# dependencies won't be the same as in development.
# rm -rf Gemfile.lock

# try to install one more time
bundle install

Bundler 仍然说...

$ bundle install --deployment
Fetching source index for https://rubygems.org/
Could not find capistrano-2.11.1 in any of the sources

好的,好的。我会删除Gemfile.lock...

$ bundle install --deployment
The --deployment flag requires a Gemfile.lock. Please make sure you have checked 
    your Gemfile.lock into version control before deploying.

如果能提供任何帮助,我将不胜感激。

【问题讨论】:

    标签: ruby-on-rails ruby ruby-on-rails-3 rubygems bundler


    【解决方案1】:

    通过出现类似的 rake-0.9.2.2 错误到达这里。发现我遗漏了适当的 require 以在我的 deploy.rb 文件中包含特定于捆绑器的 capistrano 任务:

    在您的 deploy.rb 中:

    require 'bundler/capistrano'
    require 'delayed/recipes'
    

    这最终会为您运行bundle install(带有一些不错的命令行参数)。

    另外,您的应用服务器上不需要 capistrano。您可以在 Gemfile 中让 bundler 知道这一点:

    group :development do
      gem 'capistrano'
    end
    

    现在有了 cap deploy,cap 告诉 bundler 忽略 developmenttest 组,这导致无法在生产服务器上安装 capistrano(和其他开发或测试工具)。

    【讨论】:

    • 是的!开发中不需要 capistrano,这对我来说是最好的解决方案并且对我有用。
    【解决方案2】:

    该版本的 Capistrano 已被删除,并且不再可从 ruby​​gems.org 获得。你可以在版本页面上看到https://rubygems.org/gems/capistrano/versions

    【讨论】:

    • rake-0.9.2.2 怎么样?据我所知,这还没有被猛拉。您对为什么 Bundler 通常没有像我的系统上宣​​传的那样运行有任何想法吗?
    • 老实说,我到了我意识到您使用的是 Capistrano 版本的部分,该版本被猛拉并且没有进一步阅读。这可能是一个不完整的捆绑安装。恢复您的 Gemfile.lock 删除并更新 Capistrano 的版本。如果 Gemfile 中没有指定确切的版本,则运行 bundle update capistrano。如果是,那么只需将其更改为下一个可用版本。
    • 好的,完成。你是对的。 bundle install --development 能够继续进一步。 (直到它到达 nokogiri 并因此而窒息。但这是另一个问题。)
    • Nokogiri 是用 C 语言编写的,而不仅仅是 ruby​​,因此您需要能够编译 C。我不是 Linux 人,但我敢打赌很容易弄清楚需要什么。
    猜你喜欢
    • 2017-07-18
    • 2012-03-12
    • 1970-01-01
    • 1970-01-01
    • 2017-01-13
    • 1970-01-01
    • 1970-01-01
    • 2013-02-23
    • 1970-01-01
    相关资源
    最近更新 更多