【问题标题】:Gemfile.lock does not override GemfileGemfile.lock 不会覆盖 Gemfile
【发布时间】:2012-06-21 09:37:10
【问题描述】:

我读到,在 Rails 项目的命令行中执行 bundle install 时,gem(依赖项)是从 Gemfile.lock 加载的。

但是,当启动 bundle update 时,依赖项是从 Gemfile 加载的,因此会在 Gemfile.lock 中更新值。

所以我有一个 GemFile,其中包含:

gem "airbrake", :git => "https://github.com/mico12/airbrake.git"

和一个 Gemfile.lock 包含:

GIT 远程:git://github.com/airbrake/airbrake.git
修订: 15444189dfce4916ff35f326f6c34b8dce9b933d
规格:

airbrake (3.0.9)
  activesupport
  builder

为什么当我执行bundle install 时,我会得到:

正在获取https://github.com/mico12/airbrake.git*

而不是那个(我预期的):

正在获取https://github.com/airbrake/airbrake.git*

似乎无论如何都是从 Gemfile 加载依赖项,尽管我希望指向存储库用户“airbrake”。

Gemfile 和 Gemfile.lock 之间的关系对我来说不是很清楚。

【问题讨论】:

标签: ruby gem bundler


【解决方案1】:

您在 Gemfile 中指定依赖项。当您运行bundle installbundle update 时,bundler 会安装 Gemfile 指定的 gem,并将冻结(锁定)依赖关系树写入 Gemfile.lock。

当应用程序运行时,Rails 会查看 Gemfile.lock 并加载所有 gem。

在您的示例中,由于您指定了 mico12 的空气制动分叉,bundle installbundle update 应该从 https://github.com/mico12/airbrake.git 获取。完成后,这也应该在 Gemfile.lock 文件中。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2023-03-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-04-20
    • 2021-12-02
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多