微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

即使它在 Gemfile.lock 中,如何从捆绑安装中排除 gem?

如何解决即使它在 Gemfile.lock 中,如何从捆绑安装中排除 gem?

我正在努力建立一个新的开发环境,但我意识到我面临着一个小障碍。我在生产中使用 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 构建中调用 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

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

解决方法

--without 选项的另一种选择(虽然不是那么优雅)是另一个名为 bundle-only 的 gem。它使用 CLI,可以bundle install 特定环境。好消息是这个 gem 不会占用您 Gemfile.lock 中的空间。

宝石仓库 here

运行:

  • 仅限 gem 安装包
  • 仅捆绑生产

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。