不能在来自 RubyMine 的 WSL 中 运行 rspec

Can't run rspec in WSL from RubyMine

我正在尝试从 RubyMine 触发 运行ning RSpec,当使用 WSL 到 运行 Ruby。我可以成功启动服务器但是当 运行ning RSpec 我得到这个错误:

C:\Windows\system32\wsl.exe --distribution Ubuntu --exec /bin/sh -c "export HOME=/home/pupeno && export RUBYMINE_TESTUNIT_REPORTER='/mnt/c/Program Files/JetBrains/RubyMine 2021.2.1/plugins/ruby/rb/testing/patch/testunit' && export WSL_DISTRO_NAME=Ubuntu && export TEAMCIY_RAKE_TU_AUTORUNNER_PATH=/home/pupeno/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/test-unit-3.3.7/lib/test/unit/autorunner.rb && export SHELL=/bin/sh && export LOGNAME=pupeno && export WSLENV='' && export HOSTTYPE=x86_64 && export ANSICON='' && export TERM=xterm-256color && export NAME=assc && export DISABLE_SPRING=true && export RUBYLIB='/mnt/c/Program Files/JetBrains/RubyMine 2021.2.1/plugins/ruby/rb/testing/patch/common:/mnt/c/Program Files/JetBrains/RubyMine 2021.2.1/plugins/ruby/rb/testing/patch/rake:/mnt/c/Program Files/JetBrains/RubyMine 2021.2.1/plugins/ruby/rb/testing/patch/testunit' && export TEAMCITY_RAKE_RUNNER_USED_FRAMEWORKS=':test_unit :shoulda ' && export USER=pupeno && export SPEC_OPTS='--require teamcity/spec/runner/formatter/teamcity/formatter --format Spec::Runner::Formatter::TeamcityFormatter' && export PWD='/mnt/c/Program Files/JetBrains/RubyMine 2021.2.1/jbr/bin' && export PATH='$PATH:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/mnt/c/Program' && export LANG=C.UTF-8 && export RM_INFO=RM-212.5080.58 && export TEAMCITY_RAKE_RUNNER_MODE=idea && export TEAMCITY_RAKE_TU_TESTRUNNERMADIATOR_PATH=/home/pupeno/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/test-unit-3.3.7/lib/test/unit/ui/testrunnermediator.rb && cd /mnt/c/Users/pupeno/Code/PandemicAssistant && bash -c 'env RBENV_VERSION=3.0.2 /home/pupeno/.rbenv/bin/rbenv exec ruby /home/pupeno/.rbenv/versions/3.0.2/bin/rails spec'"
Testing started at 10:22 ...
/home/pupeno/.rbenv/versions/3.0.2/bin/ruby -I/home/pupeno/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/rspec-core-3.10.1/lib:/home/pupeno/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/rspec-support-3.10.2/lib /home/pupeno/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/rspec-core-3.10.1/exe/rspec --pattern spec/\*\*\{,/\*/\*\*\}/\*_spec.rb
/home/pupeno/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/rspec-core-3.10.1/lib/rspec/core/formatters.rb:235:in `require': cannot load such file -- spec/runner/formatter/teamcity_formatter (LoadError)
    from /home/pupeno/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/rspec-core-3.10.1/lib/rspec/core/formatters.rb:235:in `rescue in custom_formatter'
    from /home/pupeno/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/rspec-core-3.10.1/lib/rspec/core/formatters.rb:232:in `custom_formatter'
    from /home/pupeno/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/rspec-core-3.10.1/lib/rspec/core/formatters.rb:183:in `find_formatter'
    from /home/pupeno/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/rspec-core-3.10.1/lib/rspec/core/formatters.rb:152:in `add'
    from /home/pupeno/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/rspec-core-3.10.1/lib/rspec/core/configuration.rb:974:in `add_formatter'
    from /home/pupeno/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/rspec-core-3.10.1/lib/rspec/core/configuration_options.rb:118:in `block in load_formatters_into'
    from /home/pupeno/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/rspec-core-3.10.1/lib/rspec/core/configuration_options.rb:118:in `each'
    from /home/pupeno/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/rspec-core-3.10.1/lib/rspec/core/configuration_options.rb:118:in `load_formatters_into'
    from /home/pupeno/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/rspec-core-3.10.1/lib/rspec/core/configuration_options.rb:24:in `configure'
    from /home/pupeno/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/rspec-core-3.10.1/lib/rspec/core/runner.rb:132:in `configure'
    from /home/pupeno/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/rspec-core-3.10.1/lib/rspec/core/runner.rb:99:in `setup'
    from /home/pupeno/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/rspec-core-3.10.1/lib/rspec/core/runner.rb:86:in `run'
    from /home/pupeno/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/rspec-core-3.10.1/lib/rspec/core/runner.rb:71:in `run'
    from /home/pupeno/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/rspec-core-3.10.1/lib/rspec/core/runner.rb:45:in `invoke'
    from /home/pupeno/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/rspec-core-3.10.1/exe/rspec:4:in `<main>'
/home/pupeno/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/rspec-core-3.10.1/lib/rspec/core/formatters.rb:233:in `block in custom_formatter': uninitialized constant Spec (NameError)
Did you mean?  RSpec
    from /home/pupeno/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/rspec-core-3.10.1/lib/rspec/core/formatters.rb:233:in `each'
    from /home/pupeno/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/rspec-core-3.10.1/lib/rspec/core/formatters.rb:233:in `inject'
    from /home/pupeno/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/rspec-core-3.10.1/lib/rspec/core/formatters.rb:233:in `custom_formatter'
    from /home/pupeno/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/rspec-core-3.10.1/lib/rspec/core/formatters.rb:183:in `find_formatter'
    from /home/pupeno/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/rspec-core-3.10.1/lib/rspec/core/formatters.rb:152:in `add'
    from /home/pupeno/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/rspec-core-3.10.1/lib/rspec/core/configuration.rb:974:in `add_formatter'
    from /home/pupeno/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/rspec-core-3.10.1/lib/rspec/core/configuration_options.rb:118:in `block in load_formatters_into'
    from /home/pupeno/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/rspec-core-3.10.1/lib/rspec/core/configuration_options.rb:118:in `each'

An error occurred while loading teamcity/spec/runner/formatter/teamcity/formatter.
    from /home/pupeno/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/rspec-core-3.10.1/lib/rspec/core/configuration_options.rb:118:in `load_formatters_into'
Failure/Error: __send__(method, file)
    from /home/pupeno/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/rspec-core-3.10.1/lib/rspec/core/configuration_options.rb:24:in `configure'
    from /home/pupeno/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/rspec-core-3.10.1/lib/rspec/core/runner.rb:132:in `configure'

LoadError:
    from /home/pupeno/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/rspec-core-3.10.1/lib/rspec/core/runner.rb:99:in `setup'
  cannot load such file -- teamcity/spec/runner/formatter/teamcity/formatter
    from /home/pupeno/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/rspec-core-3.10.1/lib/rspec/core/runner.rb:86:in `run'
    from /home/pupeno/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/rspec-core-3.10.1/lib/rspec/core/runner.rb:71:in `run'
# /home/pupeno/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/rspec-core-3.10.1/lib/rspec/core/configuration.rb:2112:in `require'
    from /home/pupeno/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/rspec-core-3.10.1/lib/rspec/core/runner.rb:45:in `invoke'
# /home/pupeno/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/rspec-core-3.10.1/lib/rspec/core/configuration.rb:2112:in `load_file_handling_errors'
    from /home/pupeno/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/rspec-core-3.10.1/exe/rspec:4:in `<main>'
# /home/pupeno/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/rspec-core-3.10.1/lib/rspec/core/configuration.rb:1574:in `block in requires='
# /home/pupeno/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/rspec-core-3.10.1/lib/rspec/core/configuration.rb:1574:in `each'
# /home/pupeno/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/rspec-core-3.10.1/lib/rspec/core/configuration.rb:1574:in `requires='
# /home/pupeno/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/rspec-core-3.10.1/lib/rspec/core/configuration_options.rb:113:in `block in process_options_into'
# /home/pupeno/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/rspec-core-3.10.1/lib/rspec/core/configuration_options.rb:112:in `each'
# /home/pupeno/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/rspec-core-3.10.1/lib/rspec/core/configuration_options.rb:112:in `process_options_into'
# /home/pupeno/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/rspec-core-3.10.1/lib/rspec/core/configuration_options.rb:22:in `configure'
# /home/pupeno/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/rspec-core-3.10.1/lib/rspec/core/runner.rb:132:in `configure'
# /home/pupeno/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/rspec-core-3.10.1/lib/rspec/core/runner.rb:99:in `setup'
# /home/pupeno/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/rspec-core-3.10.1/lib/rspec/core/runner.rb:86:in `run'
# /home/pupeno/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/rspec-core-3.10.1/lib/rspec/core/runner.rb:71:in `run'
# /home/pupeno/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/rspec-core-3.10.1/lib/rspec/core/runner.rb:45:in `invoke'
# /home/pupeno/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/rspec-core-3.10.1/exe/rspec:4:in `<main>'
/home/pupeno/.rbenv/versions/3.0.2/bin/ruby -I/home/pupeno/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/rspec-core-3.10.1/lib:/home/pupeno/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/rspec-support-3.10.2/lib /home/pupeno/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/rspec-core-3.10.1/exe/rspec --pattern spec/\*\*\{,/\*/\*\*\}/\*_spec.rb failed
# 
#   Showing full backtrace because every line was filtered out.
#   See docs for RSpec::Configuration#backtrace_exclusion_patterns and
#   RSpec::Configuration#backtrace_inclusion_patterns for more information.
No examples found.

Process finished with exit code 1

有什么想法吗?

我尝试在 bundle exec 中安装 teamcity_formatter 和 运行ning rspec 但错误是一样的。

我可以通过 运行 中的任何一个从 WSL 控制台成功 运行 它们:

我 运行宁 Ruby我的 2021.2.1,Ruby 3.0.2,Rails 6.1.4.1,RSpec 3.10.1 , rspec-rails 5.0.2.

我找到了修复方法:安装 rspec。在 rspec-rails 之上安装纯 rspec 并开始工作。我不知道为什么。