Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails 6.1, Ruby 3.0.0: tests error as they cannot load rexml

I've created a new Rails 6.1 application from scratch with Ruby 3.0.0.

I've run db:create and generated a single model with some string columns, followed by rails db:migrate.

I ran rails test but got this require rexml error:

/Users/froop/.rvm/gems/ruby-3.0.0/gems/bootsnap-1.5.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:34:in `require': cannot load such file -- rexml/document (LoadError)   from /Users/froop/.rvm/rubies/ruby-3.0.0/lib/ruby/gems/3.0.0/gems/activesupport-6.1.0/lib/active_support/dependencies.rb:332:in `block in require'   from /Users/froop/.rvm/rubies/ruby-3.0.0/lib/ruby/gems/3.0.0/gems/activesupport-6.1.0/lib/active_support/dependencies.rb:299:in `load_dependency'   from /Users/froop/.rvm/rubies/ruby-3.0.0/lib/ruby/gems/3.0.0/gems/activesupport-6.1.0/lib/active_support/dependencies.rb:332:in `require'   from /Users/froop/.rvm/gems/ruby-3.0.0/gems/selenium-webdriver-3.142.7/lib/selenium/webdriver/firefox.rb:22:in `<main>'   from /Users/froop/.rvm/gems/ruby-3.0.0/gems/bootsnap-1.5.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'   from /Users/froop/.rvm/gems/ruby-3.0.0/gems/bootsnap-1.5.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'   from /Users/froop/.rvm/gems/ruby-3.0.0/gems/bootsnap-1.5.1/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'   from /Users/froop/.rvm/gems/ruby-3.0.0/gems/bootsnap-1.5.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'   from /Users/froop/.rvm/gems/ruby-3.0.0/gems/bootsnap-1.5.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'   from /Users/froop/.rvm/rubies/ruby-3.0.0/lib/ruby/gems/3.0.0/gems/activesupport-6.1.0/lib/active_support/dependencies.rb:332:in `block in require'   from /Users/froop/.rvm/rubies/ruby-3.0.0/lib/ruby/gems/3.0.0/gems/activesupport-6.1.0/lib/active_support/dependencies.rb:299:in `load_dependency'   from /Users/froop/.rvm/rubies/ruby-3.0.0/lib/ruby/gems/3.0.0/gems/activesupport-6.1.0/lib/active_support/dependencies.rb:332:in `require'   from /Users/froop/.rvm/gems/ruby-3.0.0/gems/webdrivers-4.4.1/lib/webdrivers/geckodriver.rb:72:in `<main>'   from /Users/froop/.rvm/gems/ruby-3.0.0/gems/bootsnap-1.5.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'   from /Users/froop/.rvm/gems/ruby-3.0.0/gems/bootsnap-1.5.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'   from /Users/froop/.rvm/gems/ruby-3.0.0/gems/bootsnap-1.5.1/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'   from /Users/froop/.rvm/gems/ruby-3.0.0/gems/bootsnap-1.5.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'   from /Users/froop/.rvm/gems/ruby-3.0.0/gems/bootsnap-1.5.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'   from /Users/froop/.rvm/rubies/ruby-3.0.0/lib/ruby/gems/3.0.0/gems/activesupport-6.1.0/lib/active_support/dependencies.rb:332:in `block in require'   from /Users/froop/.rvm/rubies/ruby-3.0.0/lib/ruby/gems/3.0.0/gems/activesupport-6.1.0/lib/active_support/dependencies.rb:299:in `load_dependency'   from /Users/froop/.rvm/rubies/ruby-3.0.0/lib/ruby/gems/3.0.0/gems/activesupport-6.1.0/lib/active_support/dependencies.rb:332:in `require'   from /Users/froop/.rvm/gems/ruby-3.0.0/gems/webdrivers-4.4.1/lib/webdrivers.rb:4:in `<main>'   from /Users/froop/.rvm/gems/ruby-3.0.0/gems/bootsnap-1.5.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'   from /Users/froop/.rvm/gems/ruby-3.0.0/gems/bootsnap-1.5.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'   from /Users/froop/.rvm/gems/ruby-3.0.0/gems/bootsnap-1.5.1/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'   from /Users/froop/.rvm/gems/ruby-3.0.0/gems/bootsnap-1.5.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'   from /Users/froop/.rvm/gems/ruby-3.0.0/gems/bootsnap-1.5.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'   from /Users/froop/.rvm/rubies/ruby-3.0.0/lib/ruby/3.0.0/bundler/runtime.rb:66:in `block (2 levels) in require'   from /Users/froop/.rvm/rubies/ruby-3.0.0/lib/ruby/3.0.0/bundler/runtime.rb:61:in `each'   from /Users/froop/.rvm/rubies/ruby-3.0.0/lib/ruby/3.0.0/bundler/runtime.rb:61:in `block in require'   from /Users/froop/.rvm/rubies/ruby-3.0.0/lib/ruby/3.0.0/bundler/runtime.rb:50:in `each'   from /Users/froop/.rvm/rubies/ruby-3.0.0/lib/ruby/3.0.0/bundler/runtime.rb:50:in `require'   from /Users/froop/.rvm/rubies/ruby-3.0.0/lib/ruby/3.0.0/bundler.rb:174:in `require'   from /Users/froop/Rails/froop_app/config/application.rb:7:in `<top (required)>'   from /Users/froop/.rvm/gems/ruby-3.0.0/gems/spring-2.1.1/lib/spring/application.rb:92:in `require'   from /Users/froop/.rvm/gems/ruby-3.0.0/gems/spring-2.1.1/lib/spring/application.rb:92:in `preload'   from /Users/froop/.rvm/gems/ruby-3.0.0/gems/spring-2.1.1/lib/spring/application.rb:157:in `serve'   from /Users/froop/.rvm/gems/ruby-3.0.0/gems/spring-2.1.1/lib/spring/application.rb:145:in `block in run'   from /Users/froop/.rvm/gems/ruby-3.0.0/gems/spring-2.1.1/lib/spring/application.rb:139:in `loop'   from /Users/froop/.rvm/gems/ruby-3.0.0/gems/spring-2.1.1/lib/spring/application.rb:139:in `run'   from /Users/froop/.rvm/gems/ruby-3.0.0/gems/spring-2.1.1/lib/spring/application/boot.rb:19:in `<top (required)>'   from <internal:/Users/froop/.rvm/rubies/ruby-3.0.0/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require'   from <internal:/Users/froop/.rvm/rubies/ruby-3.0.0/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require'   from -e:1:in `<main>' 

I'm not at all sure what's causing this. Rails is up to date. Can anyone point me in the right direction?

like image 215
user3574603 Avatar asked Dec 28 '20 15:12

user3574603


2 Answers

rexml gem is a bundled gem since Ruby 3.0.0. So you must add rexml to Gemfile.

On Ruby 2.6 and 2.7, rexml gem is default gem. So default rexml is used if Gemfile does not include rexml. On these versions of ruby, you must add rexml to Gemfile only if you want to use specific rexml version.

like image 138
Kazuhiro NISHIYAMA Avatar answered Sep 28 '22 02:09

Kazuhiro NISHIYAMA


To install rexml just paste: gem 'rexml', '~> 3.2', '>= 3.2.4' in Gemfile. You can find it at https://rubygems.org/gems/rexml

like image 28
antoniolulee Avatar answered Sep 28 '22 01:09

antoniolulee