捆绑软件:不支持在使​​用系统gem时使用自定义路径 [英] bundler: Using a custom path while using system gems is unsupported

查看:85
本文介绍了捆绑软件:不支持在使​​用系统gem时使用自定义路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 GitLab-CI / CD 构建我的 Rails 应用程序。我注意到由于不支持在使​​用系统gems时使用自定义路径而导致构建失败错误,该错误以前运行得很好。

I am using GitLab-CI/CD to build my Rails application. I have noticed my builds are failing due to Using a custom path while using system gems is unsupported error, which were working perfectly fine before.

试图检查较新的更新版本,但未发现任何问题。有没有人对最近的更新有任何想法或对提到的问题有什么看法?

Tried to check newer update releases but didn't find any issues. Does any one have any idea on recent updates or somthing on mentioned issue?

同胞是我的 gitlab-ci.yml

variables:
  GIT_SUBMODULE_STRATEGY: recursive

cache:
  key: ${CI_JOB_NAME}
  paths:
    - vendor/ruby

before_script:
    - apt-get update -qq
    - ruby -v
    - which ruby
    - gem --version
    - git --version
    - gem update --system 2.7.6
    - gem install bundler -v 2.0.1
    - bundle -v
    - bundle config ${REPO_URL} ${BUNDLE_GITLAB__TOKEN}
    - bundle config --global disable_shared_gems true
    - bundle install --jobs $(nproc)  "${FLAGS[@]}" --path vendor 

rubocop:
  tags:
    - rubocop
  script:
    - bundle exec rubocop

# rspec:
#   stage: test
#   script:
#     - bundle exec rspec

下面是我得到的简短错误

And bellow is the brief error I'm getting

$ apt-get update -qq
$ ruby -v
ruby 2.5.5p157 (2019-03-15 revision 67260) [x86_64-linux]
$ which ruby
/usr/local/bin/ruby
$ gem --version
3.0.3
$ git --version
git version 2.20.1
$ gem update --system 2.7.6
Updating rubygems-update
Successfully installed rubygems-update-2.7.6
Installing RubyGems 2.7.6
Bundler 1.16.1 installed
RubyGems 2.7.6 installed
Regenerating binstubs



------------------------------------------------------------------------------

RubyGems installed the following executables:
    /usr/local/bin/gem
    /usr/local/bin/bundle

RubyGems system software updated
$ gem install bundler -v 2.0.1
Successfully installed bundler-2.0.1
1 gem installed
$ bundle -v
Bundler version 2.0.1
$ bundle config https://gitlab.com/dharshannn/test-star.git ${BUNDLE_GITLAB__TOKEN}
$ bundle config --global disable_shared_gems true
$ bundle install --jobs $(nproc)  "${FLAGS[@]}" --path vendor
Using a custom path while using system gems is unsupported.

path:
Set for your local app (/usr/local/bundle/config): "vendor"

path.system:
Set via BUNDLE_PATH__SYSTEM: true

disable_shared_gems:
Set for the current user (/root/.bundle/config): true
ERROR: Job failed: exit code 1


推荐答案

今天我也发生了同样的事情。我很确定没有对 bundler gem 进行更新。但是,Docker映像已更新(我正在使用 ruby​​:2.6.3 )。当这种情况开始发生时,我还添加了一个新的依赖项,因此我怀疑它依赖于已安装在系统路径中的gem,因此会出现错误消息。

The same happened to me today. I am pretty sure that there was no update to bundler or gem. The Docker image however has been updated (I was using ruby:2.6.3). I also added a new dependency when this started happening, so I suspect it was dependent on a gem which was already installed in the system path thus the error message.

您可以通过在 .gitlab-ci.yml 中指定以下配置变量来解决该问题:

You can get around it by specifying the following configuration variables in your .gitlab-ci.yml:

variables:
  BUNDLE_DISABLE_SHARED_GEMS: "true"
  BUNDLE_PATH__SYSTEM: "false"

这将配置Bundler不使用共享的gem,并完全禁用系统gem。

This will configure Bundler to not use shared gems and disable system gems fully.

请参见 https://bundler.io/v2.0/bundle_config.html


disable_shared_gems(BUNDLE_DISABLE_SHARED_GEMS):阻止Bundler访问安装到RubyGems正常位置的宝石。

disable_shared_gems (BUNDLE_DISABLE_SHARED_GEMS): Stop Bundler from accessing gems installed to RubyGems' normal location.


path.system(BUNDLE_PATH__SYSTEM):Bundler是否将gems安装到默认系统中m路径(Gem.dir)。

path.system (BUNDLE_PATH__SYSTEM): Whether Bundler will install gems into the default system path (Gem.dir).

这篇关于捆绑软件:不支持在使​​用系统gem时使用自定义路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆