ruby - 无法在 Windows 上安装 Watir

标签 ruby rubygems watir

我们一直在使用 ruby​​ 和 Watir 进行自动化工作,但是最近我们开始面临一个新问题。我们无法在新机器上安装 Watir。 我们安装了 ruby​​ 186_27_rc2,然后更新了 gems。当前‘gem-v’显示已安装 1.3.7。 但是,当我们运行“gem install watir”时,我们会收到错误

C:\>gem -v
1.3.7

C:\>gem install watir
Building native extensions. This could take a while…
ERROR: Error installing watir:
ERROR: Failed to build gem native extension.

C:/Ruby/bin/ruby.exe extconf.rb
checking for strncpy_s()… no
creating Makefile

nmake

Microsoft (R) Program Maintenance Utility Version 1.50
Copyright (c) Microsoft Corp 1988-94. All rights reserved.

cl -nologo -I. -I. -IC:/Ruby/lib/ruby/1.8/i386-mswin32 -I. -MD -Zi -O2b2 xg- -G6 -c -Tcwin32/api.c
‘cl’ is not recognized as an internal or external command,
operable program or batch file.
NMAKE : fatal error U1077: ‘C:\WINDOWS\system32\cmd.exe’ : return code ’0×1′
Stop.

Gem files will remain installed in C:/Ruby/lib/ruby/gems/1.8/gems/win32-api-1.4. 8 for inspection.
Results logged to C:/Ruby/lib/ruby/gems/1.8/gems/win32-api-1.4.8/ext/gem_make.out

问候 因德尔

最佳答案

这可能是由最新的 win32-api gem 引起的错误。根据您的错误消息,C 扩展源文件 api.c(属于 Watir 的依赖项之一 win32-api)无法编译,因为找不到 cl.exe(命令行 MS C++ 编译器):

cl -nologo -I. -I. -IC:/Ruby/lib/ruby/1.8/i386-mswin32 -I. -MD -Zi -O2b2 xg- -G6 -c -Tcwin32/api.c

‘cl’ is not recognized as an internal or external command, operable program or batch file.

正如 Iain 的回答所述,如果您的 PATH 中有 cl.exe 的副本,这可能会起作用,但您可能可以不这样做。

在“gem install watir”之前,尝试安装 win32-api 1.4.5 版本(包含预构建的二进制文件):

gem install win32-api --version 1.4.5

请参阅此帖子了解 2010 年初的类似情况:

http://groups.google.com/group/watir-general/browse_thread/thread/9873479c1a430137

关于ruby - 无法在 Windows 上安装 Watir,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4918596/

相关文章:

javascript - 外部 gem 的 Assets 管道编码问题(UTF-8 与 ASCII-8BIT)

ruby-on-rails - 有人知道在 Amazon S3 上存储 Rails 页面缓存的简单方法吗?

ruby-on-rails - 无法加载此类文件 -- 捆绑程序/设置 (LoadError) ||在 Ubuntu 12.04 x32 上部署

ruby - 在 ruby​​ 单元测试中访问全局变量

ruby - POST json 数据和自定义 header

ruby-on-rails - 如何在没有循环依赖的情况下使用 Thinking Sphinx 在 Rails 5 中索引多态 (STI) 模型?

ruby-on-rails - 如何在 Ruby/Rails 中匹配和替换模板标签?

ruby - puppet-lint 忽略 ignore_paths 选项

ruby - Selenium::WebDriver::Error::WebDriverError:无法连接到 chromedriver

firefox - 在 Firefox 中添加安全异常(exception)