错误“无法在RubyMine中加载此类文件 - 2.0 / Console_ext”运行单元测试

时间:2013-09-19 22:15:22

标签: ruby rubymine minitest

我正在尝试开始在rails应用程序上运行示例ruby的单元测试,但每当我尝试运行单元测试时,RubyMine就会打印出以下错误

Screenshot of the error

我在运行bundle install时也遇到了同样的错误,因为我已将gem "win32console", '1.3.0'添加到我的Gemfile中。这是文本形式的错误

      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>'"]

此错误的原因是什么?我该如何解决?

2 个答案:

答案 0 :(得分:9)

使用Ruby 2.0时不需要win32console。 Windows上的Ruby 2.0支持ANSI转义序列,正确支持unicode字符输出。所以win32console gem是不必要的。删除它。

win32Console也是一个老宝石 - 认为它们不支持Ruby 2.0

答案 1 :(得分:0)

我的解决方案是在我的Gemfile中简单地注释掉对win32console的引用。感谢您之前的回答,指出了这一点。

在这种情况下,我的错误是:c:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/win32console-1.3.2-x86-mingw32/lib/Win32/Console.rb: 12:在`require&#39;:无法加载这样的文件 - 2.0 / Console_ext(LoadError)

这允许测试运行,以及捆绑安装。长期我可能会删除参考。