【问题标题】:Running "bundle install" fails and asks me to run "bundle install"运行“捆绑安装”失败并要求我运行“捆绑安装”
【发布时间】:2011-08-07 07:07:56
【问题描述】:

事实上,当从我从 git repo 克隆的现有 rails 应用程序中运行时,所有与 gem 相关的命令都会产生相同的错误消息。

$ bundle install
Could not find tzinfo-0.3.27 in any of the sources
Run `bundle install` to install missing gems.

$ gem list
Could not find tzinfo-0.3.27 in any of the sources
Run `bundle install` to install missing gems.

$ bundle update
Could not find tzinfo-0.3.27 in any of the sources
Run `bundle install` to install missing gems.

$ rails -v
Could not find tzinfo-0.3.27 in any of the sources
Run `bundle install` to install missing gems.

我以为我已经安装了 rails...(以下命令是从 app 目录之外运行的):

$ rails -v
Rails 3.0.3

$ ruby -v
ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-darwin11.0.0]

知道“捆绑安装”告诉我运行“捆绑安装”是怎么回事吗??


我退出了我的应用目录并手动退出了

sudo gem install tzinfo -v 0.3.27

但是再次进入我的应用目录并尝试“捆绑安装”...

$ bundle install
Could not find polyglot-0.3.1 in any of the sources
Run `bundle install` to install missing gems.

所以我退出了应用程序目录,是的

sudo gem install polyglot -v 0.3.1

“捆绑安装”现已完成

$ bundle install
Could not find treetop-1.4.9 in any of the sources
Run `bundle install` to install missing gems.

为什么我必须手动安装所有这些我过去不需要的随机 gem? (新的开发环境)。任何人都知道我在我的环境中设置的错误吗?

【问题讨论】:

  • 您的 Gemfile 中有什么,是否包含 source 'http://rubygems.org'
  • 它包含源:rubygems,添加源 'rubygems.org' 没有帮助,同样的错误。
  • 另外...事实证明我可以运行bundle install --gemfile=myApp/Gemfile,但它因另一个错误而失败(我认为不相关)。为什么我不能从 app 目录中运行 bundle install?

标签: ruby-on-rails ruby installation rvm bundle


【解决方案1】:

好吧,我想我修好了..

对于运行bundle install 抱怨从应用程序目录内部运行的gem,我通过离开应用程序目录并逐一执行sudo gem install [gem] 来安装它们。执行bundle install --gemfile=myApp/Gemfile 还安装了一些缺少的 gem。

我不知道为什么我不能从 app 目录中运行 bundle install...很糟糕。

【讨论】:

  • 当您执行“gem install”时,它会将其全局安装到您的 ruby​​ 版本(假设您使用的是 Rbenv),因此“gem list”会显示这些。当您进行捆绑安装时,它会为特定项目安装 gem,在您的项目文件夹中的“bundle show”将显示该项目的 gem。当您有很多项目时,您不想污染您的全局 gem - 它们应该(意见,最佳实践)在每个项目的基础上安装。
  • 尝试使用bundle update 而不是bundle install。为我解决了这个问题
  • 同意@ConnorLeech。 bundle update 也是对我有用的简单解决方案。
  • 我通过运行$gem install bundler 解决了这个问题。这将更新(或安装)您可能已过时的捆绑程序。更详细的解释请查看this article
【解决方案2】:

我遇到了这个问题。一旦我这样做了:

[root@smaug ~]# PATH=$PATH:~/.gem/ruby/2.0.0/bin

[root@smaug ~]# export PATH

然后它被修复了,我就可以了

[root@smaug msf3]# bundle install

成功了。

【讨论】:

  • 对我来说,问题在于配置的~/.gemrc 文件。不错的其他地方。
【解决方案3】:

问题是您的所有命令实际上都预先添加了bundle exec。如果你看一下输出,它是 bundler 告诉你你的 gem 没有安装。如果您在 rbenv 中安装了一些插件,例如 rbenv-bundle-exec、rbenv-bundler 或 rbenv-binstubs,就会发生这种情况。 至少对我而言,这是您第一次尝试在项目中使用 bundle install 时发生的,因为它实际上检测到当前文件夹中有一个 Gemfile 并尝试执行 bundle exec bundle install 这显然是行不通的。

您可以使用 Tim 的解决方案,并从项目文件夹之外运行 bundle install。

您可以暂时禁用或卸载将 bundle exec 附加到 ruby​​ 命令的扩展。

或者如果问题是因为您使用 rbenv-bundle-exec 而发生的,请执行以下操作:

NO_BUNDLE_EXEC=1 bundle install

【讨论】:

    【解决方案4】:

    rubyinstaller 安装 ruby​​

    然后gem install bundle 在 win 10 PC 上为我解决了这个问题。

    【讨论】:

      【解决方案5】:

      bundle exec bash会有同样的效果

      确保未设置BUNDLER_ORIG_* 环境变量。

      如果是,则表明您处于bundle exec 子进程中。

      【讨论】:

        【解决方案6】:

        我遇到了一个非常相似的问题,在尝试了许多不同的事情之后,我终于找到了一个简单的解决方案......我重新启动了我的计算机(mac os 10.9x)。不是开玩笑。

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2015-10-19
          • 2018-12-02
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多