问题描述
我使用 Ruby 3.0.0 从头开始创建了一个新的 Rails 6.1 应用程序.
I've created a new Rails 6.1 application from scratch with Ruby 3.0.0.
我运行了 db:create
并生成了一个带有一些字符串列的单个模型,然后是 rails db:migrate
.
I've run db:create
and generated a single model with some string columns, followed by rails db:migrate
.
我运行了 rails test
但得到这个需要 rexml 错误:
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>'
我完全不确定是什么原因造成的.Rails 是最新的.有人能指出我正确的方向吗?
I'm not at all sure what's causing this. Rails is up to date. Can anyone point me in the right direction?
推荐答案
rexml
gem 是自 Ruby 3.0.0 以来捆绑的 gem.所以你必须将 rexml
添加到 Gemfile
中.
rexml
gem is a bundled gem since Ruby 3.0.0.So you must add rexml
to Gemfile
.
在 Ruby 2.6 和 2.7 上,rexml
gem 是默认 gem.因此,如果 Gemfile
不包含 rexml
,则使用默认的 rexml
.在这些版本的 ruby 上,只有当您想使用特定的 rexml
版本时,才必须将 rexml
添加到 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.
这篇关于Rails 6.1、Ruby 3.0.0:测试错误,因为它们无法加载 rexml的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!