- 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)
A lot of the discussions I found on this error were pretty old. Then, finally stumbled upon this recent github discussion:
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