Cannot run my Rspec tests
已回答
OS: Windows 10
RubyMine version: 2024.3.2
Ruby Version: ruby 3.4.1 (2024-12-25 revision 48d4efcb85) +PRISM [x64-mingw-ucrt]
The issue: I cannot run my Rspec tests thru RubyMine. When I hit to run any of my tests Edit Configurations windows popup with the Error: Cannot find RSpec runner script for ruby-3.4.1-p0 SDK. However I can easily run it thru command line by executing bundle exec rspec spec/test_spec.rb
My gem file looks like
# frozen_string_literal: true
source 'https://rubygems.org'
ruby ‘3.4.1’
gem 'rspec'
Outcome for my bundle list
Gems included by the bundle:
* diff-lcs (1.5.1)
* rspec (3.13.0)
* rspec-core (3.13.2)
* rspec-expectations (3.13.3)
* rspec-mocks (3.13.2)
* rspec-support (3.13.2)
请先登录再写评论。
Actually, I found a temporary solution. The problem is that the latest Ruby versions store RSpec and other gem executables in different locations compared to previous Ruby versions.
For example, Ruby 3.0.2 stores RSpec within the Ruby folder; in my case, it was
C:\Ruby31-x64.When I updated Ruby to version 3.4.1, I noticed that RSpec is now located in a different directory. In my case, it was:
C:\Users\Admin\AppData\Local\Microsoft\WindowsApps\rspec. (you can check rspec path by typing which rspec in MINGW console. e.g. git consoleIt seems that RubyMine IDE only looks for RSpec within the Ruby folder. As a workaround, specifying the path directly solves the problem. You can configure this in RSpec Run/Debug Configuration Templates.
I hope my solution helps anyone facing the same issue, and I also hope JetBrains fixes this so we can run RSpec without having to specify the path manually.
Hello,
Thank you for the report and for the investigation. I've submitted an issue on our tracker so could you please add your vote there:
https://youtrack.jetbrains.com/issue/RUBY-34531/Cannot-run-RSpec-tests-on-Windows-with-Ruby-3.4
Thank you Slapperywd
This is still an issue. I have voted on the tracker issue but wanted to say that I think this is affecting other gems potentially, I cannot get Rubocop linter to work and there doesn't seem to be a workaround. There isn't any way to point to a different Rubocop location.
For anyone having this issue I found a temporary fix
Settings > Language & Frameworks > Ruby Interpreters
change the ruby version to any other version
click apply
change the ruby version back
click apply
I have had a few issues that all seem to be caused by rubymine not loading the current version of ruby properly so changing the version and changing it back seems to solve the issue but it eventually happens again