bundler: Using a custom path while using system gems is unsupported - ruby-on-rails

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

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

Related

I can't execute $ bundle exec rake secret, because I don't know how to get rid of /usr/local/bin/bundle. And should I reinstall the Xcode?

My ruby ​​version is 2.3.0, my mysql version is 8.0.23, my mysql2 version is 0.5.3, my rails version is 5.0.7.2, and my Xcode version is 12.5.
I use macOS Big Sur(version 11.4) and the text editor "Atom".
I'm planning to release my Rails application with the URL of HEROKU(example. https://[My APP Name].herokuapp.com).
I ran the following command.
$ bundle exec rake secret
bash: /usr/local/bin/bundle: /System/Library/Frameworks/Ruby.framework/Versions/2.3/
usr/bin/ruby: bad interpreter: No such file or directory
I installed the ruby version "2.3.0" as below ,because bundle seems to call "2.3".
$ rbenv install 2.3.0
Downloading openssl-1.0.2u.tar.gz...
-> https://****
Installing openssl-1.0.2u...
Installed openssl-1.0.2u to /Users/****/.rbenv/versions/2.3.0
Downloading ruby-2.3.0.tar.bz2...
-> https://****
Installing ruby-2.3.0...
WARNING: ruby-2.3.0 is past its end of life and is now unsupported.
It no longer receives bug fixes or critical security updates.
ruby-build: using readline from homebrew
Installed ruby-2.3.0 to /Users/****/.rbenv/versions/2.3.0
I verified that the ruby version "2.3.0" is installed and the current ruby version is "2.3.0".
$ rbenv local 2.3.0
$ rbenv rehash
$ rbenv versions
system
* 2.3.0
$ rbenv global 2.3.0
$ rbenv rehash
$ rbenv versions
system
* 2.3.0
But the ruby current version is "2.6.3" when used the below command.
$ ruby -v
ruby 2.6.3p62 (2019-04-16 revision 67580) [universal.x86_64-darwin20]
$ gem env
RubyGems Environment:
- RUBYGEMS VERSION: 3.0.3
- RUBY VERSION: 2.6.3 (2019-04-16 patchlevel 62) [universal.x86_64-darwin20]
- INSTALLATION DIRECTORY: /Library/Ruby/Gems/2.6.0
- USER INSTALLATION DIRECTORY: /Users/****/.gem/ruby/2.6.0
- RUBY EXECUTABLE: /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby
- GIT EXECUTABLE: /usr/local/bin/git
- EXECUTABLE DIRECTORY: /usr/local/bin
- SPEC CACHE DIRECTORY: /Users/****/.gem/specs
- SYSTEM CONFIGURATION DIRECTORY: /Library/Ruby/Site
- RUBYGEMS PLATFORMS:
- ruby
- universal-darwin-20
- GEM PATHS:
- /Library/Ruby/Gems/2.6.0
- /Users/****/.gem/ruby/2.6.0
- /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/gems/2.6.0
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- https://rubygems.org/
- SHELL PATH:
- /usr/local/bin
- /usr/bin
- /bin
- /usr/sbin
- /sbin
- /Users/****/.rbenv/shims
I ran the following command.
$ bundle exec rake secret
bash: /usr/local/bin/bundle: /System/Library/Frameworks/Ruby.framework/Versions/2.3/
usr/bin/ruby: bad interpreter: No such file or directory
Would you like to tell me how to get rid of /usr/local/bin/bundle?
Because my bundle exec should work if I can get rid of /usr/local/bin/bundle.
And should I reinstall the Xcode ,that is command line tools? The 1st answer of the below URL recommends to try running xcode-select --install to (re)install the Xcode command line tools.
Cannot install Jekyll after updating to Catalina - An error occurred while installing ffi (1.9.18)
Looks like your /usr/local/bin/bundle precedes the bundle executable from rbenv in your PATH.
Could it be that you installed ruby with some other tools than rbenv (additionally to rbenv installation)?
In my macOS setup i do not have a file /usr/local/bin/bundle
$ ls /usr/local/bin/bundle
ls: /usr/local/bin/bundle: No such file or directory
and the bundle executable is loaded from my rbenv installation:
$ which bundle
/Users/***/.rbenv/shims/bundle
I think, if you can get rid of /usr/local/bin/bundle your bundle exec could work.
(you could try this with renaming the /usr/local/bin/bundle temporary, if you do not know how this bundle file was installed on your system)

Cannot run rails server locally wrong ruby version

I recently install ruby 2.7.1 using rbenv. I have made sure that .ruby-version and Gemfile file both have 2.7.1 as ruby version.
Now i cannot run rails s locally, doing so returns the following output in console:
Warning: the running version of Bundler (2.1.2) is older than the version that created the lockfile (2.1.4). We suggest you to upgrade to the version that created the lockfile by running gem install bundler:2.1.4.
Your Ruby version is 2.7.0, but your Gemfile specified 2.7.1
I have been searching and trying different things for hours but cannot figure out the problem and would be thankful for help.
Following output may help figure out the problem:
curl -fsSL https://github.com/rbenv/rbenv-installer/raw/master/bin/rbenv-doctor | bash
Checking for rbenv' in PATH: /usr/bin/rbenv Checking for rbenv shims in PATH: OK Checking rbenv install' support: /home/imran/.rbenv/plugins/ruby-build/bin/rbenv-install (ruby-build 20200819)
Counting installed Ruby versions: 1 versions
Checking RubyGems settings: OK
Auditing installed plugins: OK
bundle env
Environment
Bundler 2.1.4
Platforms ruby, x86_64-linux
Ruby 2.7.1p83 (2020-03-31 revision a0c7c23c9cec0d0ffcba012279cd652d28ad5bf3) [x86_64-linux]
Full Path /home/imran/.rbenv/versions/2.7.1/bin/ruby
Config Dir /home/imran/.rbenv/versions/2.7.1/etc
RubyGems 3.1.2
Gem Home /home/imran/.gem/ruby/2.7.0
Gem Path /home/imran/.gem/ruby/2.7.0:/home/imran/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0
User Home /home/imran
User Path /home/imran/.gem/ruby/2.7.0
Bin Dir /home/imran/.gem/ruby/2.7.0/bin
Tools
Git 2.25.1
RVM not installed
rbenv rbenv 1.1.1
chruby not installed
Bundler Build Metadata
Built At 2020-01-05
Git SHA 32a4159325
Released Version true
gem env
RubyGems Environment:
RUBYGEMS VERSION: 3.1.2
RUBY VERSION: 2.7.1 (2020-03-31 patchlevel 83) [x86_64-linux]
INSTALLATION DIRECTORY: /home/imran/.gem/ruby/2.7.0
USER INSTALLATION DIRECTORY: /home/imran/.gem/ruby/2.7.0
RUBY EXECUTABLE: /home/imran/.rbenv/versions/2.7.1/bin/ruby
GIT EXECUTABLE: /usr/bin/git
EXECUTABLE DIRECTORY: /home/imran/.gem/ruby/2.7.0/bin
SPEC CACHE DIRECTORY: /home/imran/.gem/specs
SYSTEM CONFIGURATION DIRECTORY: /home/imran/.rbenv/versions/2.7.1/etc
RUBYGEMS PLATFORMS:
ruby
x86_64-linux
GEM PATHS:
/home/imran/.gem/ruby/2.7.0
/home/imran/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0
GEM CONFIGURATION:
:update_sources => true
:verbose => true
:backtrace => false
:bulk_threshold => 1000
REMOTE SOURCES:
https://rubygems.org/
SHELL PATH:
/home/imran/.rbenv/versions/2.7.1/bin
/usr/lib/rbenv/libexec
/home/imran/.rbenv/plugins/ruby-build/bin
/home/imran/.rbenv/bin
/home/imran/.rbenv/shims
/home/imran/.rbenv/plugins/ruby-build/bin
/home/imran/.rbenv/bin
/home/imran/.local/bin
/home/imran/bin
/usr/local/sbin
/usr/local/bin
/usr/sbin
/usr/bin
/sbin
/bin
/usr/games
/usr/local/games
/snap/bin
/usr/local/texlive/2018/bin/x86_64-linux
my ~/.profile contains following statements:
export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"
export GEM_HOME="$(ruby -e 'puts Gem.user_dir')"
export PATH="$HOME/.rbenv/bin:$PATH"
Did You try to just update bundler as output said:
gem install bundler:2.1.4
or
gem install bundler
bundle update
rbenv creates shims based on version of ruby you install. Each time you change ruby version via rbenv global X.Y.Z or rbenv local A.B.C, rbenv will intercept the ruby command and redirect it to the appropriate ruby installation version which will look at its associated gems.
Therefore, if you set your local version to 2.7.1, and the error message you receive is telling you that your bundle version is different, you probably have not installed the bundler gem in the 2.7.1 Ruby shim.
To fix this, you can change your ruby version and install the gem:
rbenv local 2.7.1
ruby -v
# 2.7.1
gem install bundler
Now, ensure that in your Gemfile.lock you are using the same bundler version of the bundler gem you installed. If it is not, it means that the Gemfile.lock file was generated and bundled with a previous version. You can force update the Gemfile.lock by deleting and rebuilding, however, if you are collaborating with other developers you may want to speak with them before you do (and commit to source control)
#Gemfile.lock
BUNDLED_WITH 2.1.5

Install Gitlab on Mac OS 10.12 failed at 'Charlock_holmes (0.7.3)'

I want to install Gitlab on Mac OS X. Therefore I followed
Installation Guid for Gitlab on OS X
However, I get into trouble when I install ruby gems by bundle.
bundle install --deployment --without development test mysql aws kerberos
resulted in,
Gem files will remain installed in /Users/git/gitlab/vendor/bundle/ruby/2.3.0/gems/charlock_holmes-0.7.3 for inspection.
Results logged to /Users/git/gitlab/vendor/bundle/ruby/2.3.0/extensions/x86_64-darwin-16/2.3.0-static/charlock_holmes-0.7.3/gem_make.out
An error occurred while installing charlock_holmes (0.7.3), and Bundler cannot continue.
Make sure that `gem install charlock_holmes -v '0.7.3'` succeeds before bundling.
In Gemfile:
gitlab_git was resolved to 10.5.0, which depends on
github-linguist was resolved to 4.7.6, which depends on
charlock_holmes
I tried Unable to install version 0.7.3 on Mac OS Sierra in order to install charlock_holmes.
gem install charlock_holmes -v 0.7.3 -- --with-cxxflags=-std=c++11
it resulted in successfully installed.
Building native extensions with: '--with-cxxflags=-std=c++11'
This could take a while...
Successfully installed charlock_holmes-0.7.3
Parsing documentation for charlock_holmes-0.7.3
Done installing documentation for charlock_holmes after 0 seconds
1 gem installed
So I am confused why I can not keep install gems..
I install all gems by
bundle install --no-deployment --without development test mysql aws kerberos
However, I got in other error...
bundle exec rake gitlab:setup RAILS_ENV=production
resulted in,
D, [2018-01-25T16:22:14.066436 #89351] DEBUG -- sentry: ** [Raven] compared with non class/module excluded from capture due to environment or should_capture callback
rake aborted!
TypeError: compared with non class/module
I had this problem today. What fixed it for me was updating icu4c, then re-installing ruby which will compile with the updated version. I use ruby-install and chruby so it was basically like this:
$ brew upgrade icu4c
$ chruby 2.3.4 # change to previous ruby (if necessary)
$ rm -rf .rubies/ruby-2.4.4 # drop ruby compiled with old version of icu4c
$ ruby-install ruby 2.4.4 # don't forget to restart your terminal after this completes
$ ruby -e 'puts RUBY_VERSION'
2.4.4
$ bundle install # now it works!

bundle uses wrong ruby version

I'm trying to run
env RAILS_ENV=test bundle exec rake db:migrate
and get the following error
Your Ruby version is 2.1.7, but your Gemfile specified 2.2.3
ruby -v
gives me
ruby 2.2.3p173 (2015-08-18 revision 51636) [x86_64-darwin15]
I'm using rbenv, if that matters. rbenv versions gives the following:
system
* 2.2.3 (set by /Users/thatsme/Projects/demoproject/.ruby-version)
So I have no ruby 2.1.7 installed. Spring is not running and I've run rbenv rehash. Then bundler gem is installed.
I'm going nuts on this. Can somebody please tell me why the wrong ruby version is being used? Thanks!
Running the command below helped me somehow:
rbenv exec gem install bundler
Assumption: You are using RVM.
This means there's a ruby version installed outside of RVM.
Clear your rvm rubies by running
rvm uninstall <ruby version>
once you have uninstalled all rvm rubies do ruby -v, if this returns an output specifying a ruby version then thats the root of the problem. Uninstall it with
sudo apt-get remove ruby
Now install your rvm rubies with rvm install <ruby version> and set it as default rvm use <ruby version>
Now install bundler
gem install bundler
And do bundle install
TLDR;
Check really carefully the content of your .bash_profile or .bashrc file.
None of the answers actually solve my problem. So here's my solution.
This is the error that I got:
$ bundle install
Your Ruby version is 3.0.1, but your Gemfile specified 2.7.1
I checked my rbenv setup:
$ rbenv versions
system
2.4.1
2.5.0
2.7.0
* 2.7.1 (set by /Users/setoelka/awesome-project/.ruby-version)
3.0.1
I uninstall the wrong version to probably reveal a new error. I can just install it again later, I was thinking.
$ rbenv uninstall 3.0.1
It does reveal a new error:
$ bundle install
-bash: /Users/setoelka/.gem/ruby/3.0.0/bin/bundle: /Users/setoelka/.rbenv/versions/3.0.1/bin/ruby: bad interpreter: No such file or directory
Ok, that's strange. I can just remove the .gem directory there.
$ rm -rf ~/.gem/
Now another new error:
$ bundle install
-bash: /Users/setoelka/.gem/ruby/3.0.0/bin/bundle: No such file or directory
It seems like my PATH variable is messed up. So I do:
$ gem environment
RubyGems Environment:
- RUBYGEMS VERSION: 3.2.27
- RUBY VERSION: 2.7.1 (2020-03-31 patchlevel 83) [x86_64-darwin20]
- INSTALLATION DIRECTORY: /Users/setoelka/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0
- USER INSTALLATION DIRECTORY: /Users/setoelka/.local/share/gem/ruby/2.7.0
- RUBY EXECUTABLE: /Users/setoelka/.rbenv/versions/2.7.1/bin/ruby
- GIT EXECUTABLE: /usr/bin/git
- EXECUTABLE DIRECTORY: /Users/setoelka/.rbenv/versions/2.7.1/bin
- SPEC CACHE DIRECTORY: /Users/setoelka/.local/share/gem/specs
- SYSTEM CONFIGURATION DIRECTORY: /Users/setoelka/.rbenv/versions/2.7.1/etc
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-darwin-20
- GEM PATHS:
- /Users/setoelka/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0
- /Users/setoelka/.local/share/gem/ruby/2.7.0
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- https://rubygems.org/
- SHELL PATH:
- /Users/setoelka/.rbenv/versions/2.7.1/bin
- /usr/local/Cellar/rbenv/1.1.2/libexec
- /Users/setoelka/opt/anaconda3/bin
- /Users/setoelka/opt/anaconda3/condabin
- /Users/setoelka/.cargo/bin
- /Users/setoelka/.gem/ruby/3.0.0/bin
- /Users/setoelka/.nvm/versions/node/v16.5.0/bin
- /Users/setoelka/.rbenv/shims
- /Users/setoelka/.rbenv/shims
- /usr/local/bin
- /usr/bin
- /bin
- /usr/sbin
- /sbin
- /Library/Apple/usr/bin
So, it's clear I missed something when checking out my .bash_profile file. That's the problem there:
- /Users/setoelka/.gem/ruby/3.0.0/bin
That line was somehow buried under a plethora of settings inside my .bash_profile.
I had the same problem
I needed to run
bundle
to reinstall all my gems. then
bundle exec rails c

"missing required gems" error when creating the database

When I run
$ sudo RAILS_ENV=production rake db:migrate
I get the following error:
missing these required gems:
rubytree >= 0
You're running:
ruby 1.8.7.249 at /usr/bin/ruby1.8
rubygems 1.8.15 at /usr/lib/ruby/gems/1.8, /home/venkat/.gem/ruby/1.8
Run rake gems:install to install the missing gems.
venkat#ubuntu:/var/redmine$ sudo vi config/database.yml
When I try to install the rubytree gem I get the following error:
gem install rubytree --version ">= 0" ERROR: While generating documentation for rubytree-0.8.2 ... MESSAGE: exit ... RDOC args: --ri --op /usr/lib/ruby/gems/1.8/doc/rubytree-0.8.2/ri --files COPYING,API-CHANGES --title Rubytree Documentation --quiet lib History.txt Manifest.txt COPYING API-CHANGES --title rubytree-0.8.2 Documentation --quiet
There's a problem with redmine and the versions of ruby/rubygems. It doesn't detect rubytree, even though it is already installed or exists in vendor directory. See redmine issues #9815 and #9798.
You can fix this by updating redmine to the current trunk or by making the changes from revision 8214.

Resources