I'm trying to get started running unit tests for a sample ruby on rails application however RubyMine is printing out the following error whenever I try and run unit tests
I've also gotten the same error when running bundle install
since I added gem "win32console", '1.3.0'
to my Gemfile. Here is the error in text form
Exception message: cannot load such file -- 2.0/Console_ext
["D:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/win32console-1.3.0-x86-mingw32/lib/Win32/Console.rb:12:in `require'", "D:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/win32console-1.3.0-x86-mingw32/lib/Win32/Console.rb:12:in `rescue in <top (required)>'", "D:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/win32console-1.3.0-x86-mingw32/lib/Win32/Console.rb:8:in `<top (required)>'", "D:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/win32console-1.3.0-x86-mingw32/lib/Win32/Console/ANSI.rb:13:in `require'", "D:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/win32console-1.3.0-x86-mingw32/lib/Win32/Console/ANSI.rb:13:in `<top (required)>'", "D:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/win32console-1.3.0-x86-mingw32/lib/win32console.rb:1:in `require'", "D:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/win32console-1.3.0-x86-mingw32/lib/win32console.rb:1:in `<top (required)>'", "D:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/bundler-1.4.0.pre.2/lib/bundler/runtime.rb:76:in `require'", "D:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/bundler-1.4.0.pre.2/lib/bundler/runtime.rb:76:in `block (2 levels) in require'", "D:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/bundler-1.4.0.pre.2/lib/bundler/runtime.rb:72:in `each'", "D:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/bundler-1.4.0.pre.2/lib/bundler/runtime.rb:72:in `block in require'", "D:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/bundler-1.4.0.pre.2/lib/bundler/runtime.rb:61:in `each'", "D:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/bundler-1.4.0.pre.2/lib/bundler/runtime.rb:61:in `require'", "D:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/bundler-1.4.0.pre.2/lib/bundler.rb:130:in `require'", "D:/Users/Justin/Projects/Rails/blog/config/application.rb:7:in `<top (required)>'", "D:/Users/Justin/Projects/Rails/blog/config/environment.rb:2:in `require'", "D:/Users/Justin/Projects/Rails/blog/config/environment.rb:2:in `<top (required)>'", "D:/Users/Justin/Projects/Rails/blog/test/test_helper.rb:2:in `require'", "D:/Users/Justin/Projects/Rails/blog/test/test_helper.rb:2:in `<top (required)>'", "D:/Users/Justin/Projects/Rails/blog/test/controllers/comments_controller_test.rb:1:in `require'", "D:/Users/Justin/Projects/Rails/blog/test/controllers/comments_controller_test.rb:1:in `<top (required)>'", "D:/Program Files (x86)/JetBrains/RubyMine 5.4.3.2.1/rb/testing/runner/tunit_or_minitest_in_folder_runner.rb:51:in `require'", "D:/Program Files (x86)/JetBrains/RubyMine 5.4.3.2.1/rb/testing/runner/tunit_or_minitest_in_folder_runner.rb:51:in `block in require_all_test_scripts'", "D:/Program Files (x86)/JetBrains/RubyMine 5.4.3.2.1/rb/testing/runner/tunit_or_minitest_in_folder_runner.rb:44:in `each'", "D:/Program Files (x86)/JetBrains/RubyMine 5.4.3.2.1/rb/testing/runner/tunit_or_minitest_in_folder_runner.rb:44:in `require_all_test_scripts'", "D:/Program Files (x86)/JetBrains/RubyMine 5.4.3.2.1/rb/testing/runner/tunit_or_minitest_in_folder_runner.rb:134:in `<top (required)>'", "-e:1:in `load'", "-e:1:in `<main>'"]
What is the cause of this error and how can I fix it?
You no need win32console when working with Ruby 2.0. Ruby 2.0 on windows supports ANSI escape sequences, support unicode character output correctly. So the win32console gem is unnecessary. Remove it.
Also win32Console is an old gem - think they don't support Ruby 2.0
My solution was to simply comment out the reference to win32console in my Gemfile. Thank you for the previous answer that pinpointed this.
In this case, my error was: c:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/win32console-1.3.2-x86-mingw32/lib/Win32/Console.rb:12:in `require': cannot load such file -- 2.0/Console_ext (LoadError)
This allowed the test to run, as well as bundle installs. Long term I will likely delete the reference.
来源:https://stackoverflow.com/questions/18905821/error-cannot-load-such-file-2-0-console-ext-running-unit-tests-in-rubymine