如何修复 rake 测试输出中的 win32console 消息?

How to fix win32console message in rake test output?

我目前正在努力学习 Ruby Rails Windows 10.

我正在关注优秀的railstutorial by Michael Hartl

但是,当我 运行 rake test 时出现的 'gem install win32console' 消息(以及缺少颜色)让我感到困扰。我该如何解决这个问题?

示例输出:

$ bundle exec rake test
ansi: 'gem install win32console' to use color on Windows
Started

  3/3: [===================================] 100% Time: 00:00:00, Time: 00:00:00

Finished in 0.35885s
3 tests, 6 assertions, 0 failures, 0 errors, 0 skips

我的设置:

基数:Ruby 2.2 Rails Installer for Windows.
运行 命令使用 Git Bash.
我也有 minitest-reporters gem installed (step 3.7.1 of tutorial).

我尝试过的:

  1. 首先我 运行 gem install win32console 但这没有效果,即使 运行 gem list 时 gem 是可见的.

  2. 然后我看到了win32console is deprecated so I installed ansicon.
    这也没有效果。 Windows 10 似乎支持颜色。
    例如。我可以 运行 Hello World 示例 puts "\e[34mHello \e[31mWorld\e[0m"this blog 上找到,它显示蓝色和红色文本,无论是否安装了 ansicon。
    但是,颜色不会在 rake test 输出中正确显示,我仍然收到警告。

万岁成功了!

最后你的评论 Jordan plus the suggestions on Paul's Perambulations 让我明白了。

已采取的步骤,适用于任何坚持这一点的人:

  1. 下载解压win32console source
  2. 安装依赖项的特定(旧)版本:
    • gem install rake -v 10.4.2
    • gem install rake-compiler -v 0.9.9(反正这是最新的)
    • gem install hoe -v 3.7.0
  3. 运行 rake _10.4.2_ gem 在 win32console 源目录中(使用正确的版本)
  4. 运行 gem install pkg/win32console-1.3.2.gem(必须更改版本号并翻转原始说明中的斜杠)
  5. gem "win32console", '1.3.2' 添加到 Gemfile
  6. 返回项目目录并运行bundle install
  7. 终于 运行 bundle exec rake test - 信息消息消失了 并且 颜色显示正确!