ruby-lsp-rspec
ruby-lsp-rspec copied to clipboard
Run in terminal CodeLens throws LoadError
When trying to run in the terminal I'm getting this error:
ruby-lsp-test-exec bundle exec rspec -r /Users/seb/.local/share/mise/installs/ruby/3.3.7/lib/ruby/gems/3.3.0/gems/ruby-lsp-rspec-0.1
.25/lib/ruby_lsp/ruby_lsp_rspec/rspec_formatter.rb -f RubyLsp::RSpec::RSpecFormatter /Users/seb/Code/..._spec.rb:55
An error occurred while loading /Users/seb/.local/share/mise/installs/ruby/3.3.7/lib/ruby/gems/3.3.0/gems/ruby-lsp-rspec-0.1.25/lib/ruby_lsp/ruby_lsp_rspec/rspec_formatter.rb.
Failure/Error: kernel_class.send(:no_warning_require, name)
LoadError:
cannot load such file -- ruby_lsp/test_reporters/lsp_reporter
# /Users/seb/.local/share/mise/installs/ruby/3.3.7/lib/ruby/3.3.0/bundled_gems.rb:69:in `require'
It doesn't seem to be sending the correct command. I've tried setting the rspecCommand option but it doesn't help.
I'm also running into this. I've never seen ruby-lsp-test-exec before and this recently started happening.
For me, I'm getting a different error:
$ ruby-lsp-test-exec bundle exec rspec -r /Users/simmonli/.asdf/installs/r
uby/3.4.2/lib/ruby/gems/3.4.0/gems/ruby-lsp-rspec-0.1.25/lib/ruby_lsp/ruby_lsp_rspec/rspec_formatter.rb -f RubyLsp::RSpec::RSpecFormatter /Users/simmonli/repos/path/to/some_spec.rb:5
DEPRECATION WARNING: `to_time` will always preserve the full timezone rather than offset of the receiver in Rails 8.1. To opt in to the new behavior, set `config.active_support.to_time_preserves_timezone = :zone`. (called from <top (required)> at /Users/simmonli/repos/path/to/app/config/environment.rb:7)
Randomized with seed 20860
[rspec-sidekiq] WARNING! Sidekiq will *NOT* process jobs in this environment. See https://github.com/wspurgin/rspec-sidekiq/wiki/FAQ-&-Troubleshooting
Finished in 0.04391 seconds (files took 7.5 seconds to load)
3 examples, 0 failures
Randomized with seed 20860
bundler: failed to load command: rspec (/Users/simmonli/.asdf/installs/ruby/3.4.2/bin/rspec)
/Users/simmonli/.asdf/installs/ruby/3.4.2/lib/ruby/gems/3.4.0/gems/ruby-lsp-0.23.16/lib/ruby_lsp/test_reporters/lsp_reporter.rb:42:in 'start_test': unknown keyword: :line (ArgumentError)
from /Users/simmonli/.asdf/installs/ruby/3.4.2/lib/ruby/gems/3.4.0/gems/ruby-lsp-rspec-0.1.25/lib/ruby_lsp/ruby_lsp_rspec/rspec_formatter.rb:30:in 'RubyLsp::RSpec::RSpecFormatter#example_started'
The Ruby LSP is enabling the test_explorer feature by default: https://shopify.github.io/ruby-lsp/test_explorer
Fixed by updating settings.json:
"rubyLsp.featureFlags": {
"fullTestDiscovery": false
},
I can confirm that by setting the fullTestDiscovery to false Run in terminal works, but the Run lens item doesn't do anything anymore.
Confirming that this option update also fixes CodeLens Run in Terminal for me.
I'm curious, are you all running with a separate gemfile, eg.: rubyLsp.bundleGemfile defined in your settings? I had the same issue https://github.com/st0012/ruby-lsp-rspec/pull/73#issuecomment-2945920185, but solved it by adding ruby-lsp-rspec to the main gemfile.
I know this can be solved by adding ruby-lsp-rspec to the main Gemfile, but I don't want to do that.