Running a spec in RubyMine results in “cannot load such file — teamcity/spec/runner/formatter/teamcity/formatter (LoadError)”

大兔子大兔子 提交于 2019-12-18 12:43:33

问题


OS: Arch Linux, Rails version: 4, RubyMine: 6.3

When I run a spec from Tools - Run Rake Task - spec I always get this error:

/home/chylli/.rvm/gems/ruby-2.1.2@rails4/gems/rspec-core-3.0.2/lib/rspec/core/configuration.rb:1024:in `require': cannot load such file -- teamcity/spec/runner/formatter/teamcity/formatter (LoadError)

but it is OK to run 'debug spec:models'.

What I tried: I added 'ruby arguments' under Run - edit configurations:

-I$RUBYMINE_HOME/rb/testing/patch/bdd -I$RUBYMINE_HOME/rb/testing/patch/common

but it doesn't work.


回答1:


Run

spring stop

on the command line before running rake from RubyMine, or running specs directly, or doing anything else that uses spring.

You don't need to do this every time you run rake or specs or whatever in RubyMine, only if you previously started spring by running rake or doing something else that starts spring outside of RubyMine. You also don't need to spring stop when you switch from RubyMine back to the command line.

This happens because if spring is not running when you run rake or whatever outside RubyMine, spring will start and will preload your code but not RubyMine-specific code. Evidently spring doesn't know how to load missing code after it's been started.




回答2:


I took the time to fix this without the need to restart spring.

There's a Pull Request for the quick hack I made in my fork of the spring-commands-rspec gem.

But it doesn't look like that repo is active, so you can use my fix by switching your spring-commands-rspec entry to this to your Gemfile:

gem 'spring-commands-rspec', git: 'https://github.com/thewoolleyman/spring-commands-rspec.git'

HTH, :) -- Chad




回答3:


Had the same issue just today, and I had to take different actions:

spring stop would tell me that Spring is not running

So I had to

1. kill them manually

ps aux | grep spring

Would give me

thomasromera     27841   [...] | spring app    | started 23 hours ago | development mode
thomasromera     38931   [...] | spring app    | started 18 hours ago | development mode
thomasromera     54661   [...] | spring app    | started 4 mins ago | development mode
thomasromera     27840   [...] | spring server | started 23 hours ago

then kill all servers + apps

kill 27840
kill 38931
...

2. Turn off the spring pre-loader in RubyMine:

In RubyMine: CMD+Shift+A type spring pre-loader, turn it off and rerun the specs.

Don't forget to turn it on again if you need it.



来源:https://stackoverflow.com/questions/24525945/running-a-spec-in-rubymine-results-in-cannot-load-such-file-teamcity-spec-ru

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!