Running a spec in RubyMine results in "cannot load such file -- teamcity/spec/runner/formatter/teamcity/formatter (LoadError)"

Ruby on-RailsRubyRuby on-Rails-4RspecRubymine

Ruby on-Rails Problem Overview


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.

Ruby on-Rails Solutions


Solution 1 - Ruby on-Rails

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.

Solution 2 - Ruby on-Rails

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

Solution 3 - Ruby on-Rails

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.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionchylliView Question on Stackoverflow
Solution 1 - Ruby on-RailsDave SchweisguthView Answer on Stackoverflow
Solution 2 - Ruby on-RailsthewoolleymanView Answer on Stackoverflow
Solution 3 - Ruby on-RailsErowlinView Answer on Stackoverflow