【问题标题】:How to fix win32console message in rake test output?如何修复 rake 测试输出中的 win32console 消息?
【发布时间】:2016-06-15 04:49:46
【问题描述】:

我目前正在尝试在 Windows 10 上学习 Ruby on Rails。

我在关注优秀的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 (step 3.7.1 of tutorial)。

我尝试过的:

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

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

【问题讨论】:

  • 你把它添加到你的 Gemfile 了吗?
  • 啊我没想到!那可能应该解决它。但是,我实际上随后收到一条错误消息:rake aborted! LoadError:无法加载此类文件 - 2.2/Console_ext 。 . .
  • 我将按照this blog post的建议尝试重建win32console

标签: ruby-on-rails ruby rake rake-test


【解决方案1】:

万岁成功了!

最后,你的评论 Jordan 加上对 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. 在win32console源目录中运行rake _10.4.2_ gem(使用正确的版本)
  4. 运行gem install pkg/win32console-1.3.2.gem(必须更改版本号并从原始说明翻转斜线)
  5. gem "win32console", '1.3.2' 添加到 Gemfile
  6. 回到项目目录并运行bundle install
  7. 最后运行bundle exec rake test - 信息消息消失了并且颜色显示正确!

【讨论】:

    猜你喜欢
    • 2017-08-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-08-23
    • 2019-12-02
    相关资源
    最近更新 更多