Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

After updating ruby to 2.7.1 rspec tests throws error `Bundler::GemfileError for status code 4 but Bundler::GemfileError is already registered`

  • using Rails 5.2.4.3
  • Mac OSX Catalina 10.15.6

After updating ruby to 2.7.1 (via rvm) ran rspec spec and received error:

Trying to register Bundler::GemfileError for status code 4 but Bundler::GemfileError is already registered
    # /Users/----/.rvm/gems/ruby-2.7.1@xmx/gems/bundler-2.1.4/lib/bundler.rb:7:in `require_relative'
    # /Users/----/.rvm/gems/ruby-2.7.1@xmx/gems/bundler-2.1.4/lib/bundler.rb:7:in `<top (required)>'
    # ./config/boot.rb:4:in `require'
    # ./config/boot.rb:4:in `<top (required)>'
    # ./config/application.rb:1:in `require'
    # ./config/application.rb:1:in `<top (required)>'
    # ./config/environment.rb:2:in `require_relative'
    # ./config/environment.rb:2:in `<top (required)>'
    # ./spec/spec_helper.rb:18:in `require'
    # ./spec/spec_helper.rb:18:in `<top (required)>'
    # ./spec/models/activation_spec.rb:1:in `require'
    # ./spec/models/activation_spec.rb:1:in `<top (required)>
  • switching to global gemset resolved the issue, but using default gemset continued to throw the error.
  • uninstalling and reinstalling bundler did not solve the issue (ensured bundler v 2.1.4)
  • I could run by using bundle exec rspec spec (but wanted to actually solve the problem)
like image 381
ea0723 Avatar asked Aug 01 '20 20:08

ea0723


2 Answers

A lot of the discussions I found on this error were pretty old. Then, finally stumbled upon this recent github discussion:

  • https://github.com/rubygems/rubygems/issues/3551

Running the following solved my issue:

gem update --system 3.0.8 && gem update --system

Note: To run update without installing documentation

gem update --system 3.0.8 --no-document && gem update --system --no-document

like image 178
ea0723 Avatar answered Nov 10 '22 15:11

ea0723


gem update --system

it works for me

like image 24
zofy29 Avatar answered Nov 10 '22 16:11

zofy29