Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

bundler: Using a custom path while using system gems is unsupported

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?

Bellow is my 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
like image 786
Aparichith Avatar asked Jul 12 '19 11:07

Aparichith


People also ask

Why bundle install is installing gems in vendor bundle?

In deployment, isolation is a more important default. In addition, the user deploying the application may not have permission to install gems to the system, or the web server may not have permission to read them. As a result, bundle install --deployment installs gems to the vendor/bundle directory in the application.


1 Answers

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.

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"

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

See 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.

and

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

like image 177
phikes Avatar answered Nov 15 '22 07:11

phikes