【问题标题】:How to exclude a gem from bundle install even though it's in Gemfile.lock?即使它在 Gemfile.lock 中,如何从捆绑安装中排除 gem?
【发布时间】:2021-04-14 00:34:05
【问题描述】:

我正在努力建立一个新的开发环境,但我意识到我面临着一个小障碍。我在生产中使用 Sidekiq Pro,但在开发中我想避免它以防止将许可证传播给其他开发人员。

为此,在我的Gemfile 我有以下内容:

group :production do 
  source "https://gems.contribsys.com/" do
    gem "sidekiq-pro"
  end
end

但是,这个确实存在于我的Gemfile.lock 文件中:

    sidekiq-pro (5.2.1)
      connection_pool (>= 2.2.3)
      sidekiq (>= 6.1.0)

所以,当我在 docker build 中调用 bundle install 时,如何防止 bundle install 尝试使用 sidekiq-pro gem?问题是由于需要身份验证而出错:

Step 6/12 : RUN bundle install --without production
 ---> Running in 0642e1440b33
The dependency tzinfo-data (>= 0) will be unused by any of the platforms Bundler is installing for. Bundler is installing for ruby but the dependency is only for x86-mingw32, x86-mswin32, x64-mingw32, java. To add those platforms to the bundle, run `bundle lock --add-platform x86-mingw32 x86-mswin32 x64-mingw32 java`.
Authentication is required for gems.contribsys.com.
Please supply credentials for this source. You can do this by running:
 bundle config gems.contribsys.com username:password
The command '/bin/sh -c bundle install --without production' returned a non-zero code: 17
ERROR: Service 'app' failed to build

如您所见,我在 bundle install 参数中指定了 --without production,但没有运气。

【问题讨论】:

    标签: ruby-on-rails rubygems


    【解决方案1】:

    --without 选项的替代方案(虽然不是那么优雅)是另一个名为 bundle-only 的 gem。它使用 CLI,它可以bundle install 特定环境。好在这个 gem 不会占用你 Gemfile.lock 的空间。

    宝石回购here

    运行:

    • gem install bundle-only
    • 仅捆绑生产

    【讨论】:

      猜你喜欢
      • 2023-04-05
      • 1970-01-01
      • 2012-08-26
      • 1970-01-01
      • 1970-01-01
      • 2016-01-11
      • 1970-01-01
      • 1970-01-01
      • 2012-11-12
      相关资源
      最近更新 更多