我正在尝试开始使用 ruby​​ 和 Watir-webdriver 进行一些测试自动化。

sudo apt-get install ruby rubygems

sudo gem install watir-webdriver

每当我安装 gem 时,我都会收到以下错误:

[/usr/lib/ruby/gems/1.8/specifications/selenium-webdriver-2.13.0.gemspec] isn't a Gem::Specification (NilClass instead).
ERROR:  While executing gem ... (NoMethodError)
    undefined method `spec' for nil:NilClass
有帮助吗?

解决方案

该问题是由于缓存中存储了损坏的下载,因此即使在 gem uninstall 并重新安装,错误依然存在。为了强制重新下载,我清空了通过检查命令输出中的 GEM PATHS 找到的缓存目录 gem env.

其他提示

您应该尝试使用Ruby 1.9.x

最简单的方法是使用RVM:

sudo apt-get install git
bash < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer)
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # This loads RVM into a shell session.
rvm install 1.9.2
rvm use 1.9.2
gem install watir-webdriver
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top