捆绑器:不支持在使用系统 gems 时使用自定义路径
bundler: Using a custom path while using system gems is unsupported
我正在使用 GitLab-CI/CD
构建我的 Rails
应用程序。我注意到我的构建由于 Using a custom path while using system gems is unsupported
错误而失败,之前工作得很好。
尝试检查较新的更新版本,但未发现任何问题。有没有人对最近的更新或提到的问题有任何想法?
下面是我的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
下面是我得到的简短错误
$ 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,因此出现错误消息。
您可以通过在 .gitlab-ci.yml
中指定以下配置变量来绕过它:
variables:
BUNDLE_DISABLE_SHARED_GEMS: "true"
BUNDLE_PATH__SYSTEM: "false"
这会将 Bundler 配置为不使用共享 gems 并完全禁用系统 gems。
见https://bundler.io/v2.0/bundle_config.html
disable_shared_gems (BUNDLE_DISABLE_SHARED_GEMS): Stop Bundler from accessing gems installed to RubyGems' normal location.
和
path.system (BUNDLE_PATH__SYSTEM): Whether Bundler will install gems into the default system path (Gem.dir).
我正在使用 GitLab-CI/CD
构建我的 Rails
应用程序。我注意到我的构建由于 Using a custom path while using system gems is unsupported
错误而失败,之前工作得很好。
尝试检查较新的更新版本,但未发现任何问题。有没有人对最近的更新或提到的问题有任何想法?
下面是我的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
下面是我得到的简短错误
$ 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,因此出现错误消息。
您可以通过在 .gitlab-ci.yml
中指定以下配置变量来绕过它:
variables:
BUNDLE_DISABLE_SHARED_GEMS: "true"
BUNDLE_PATH__SYSTEM: "false"
这会将 Bundler 配置为不使用共享 gems 并完全禁用系统 gems。
见https://bundler.io/v2.0/bundle_config.html
disable_shared_gems (BUNDLE_DISABLE_SHARED_GEMS): Stop Bundler from accessing gems installed to RubyGems' normal location.
和
path.system (BUNDLE_PATH__SYSTEM): Whether Bundler will install gems into the default system path (Gem.dir).