您正在使用json gem的旧版本或stdlib版本

GJH*_*Hmf 11 watir watir-webdriver

我已经看到几天前在另一个线程中提到的以下问题和其他问题,但是这个问题的解决方案(对我来说)似乎没有得到解决.

我最近在我的Ruby 1.9.2-p290环境上运行了测试,当我运行测试脚本时出现以下错误:

You are using an old or stdlib version of json gem
Please upgrade to the recent version by adding this to your Gemfile:

gem 'json', '~> 1.7.7'
Run Code Online (Sandbox Code Playgroud)

当我创建一个在Windows XP上运行的全新Ruby 1.9.3-p392环境时,这个问题仍然存在(请不要问).令我困惑的是,即使我安装了json 1.7.7或1.8.0(宝石列表粘贴在下面),我仍然会在运行测试时收到此消息.它并没有真正影响我的测试结果,但每次看到这个警告都很烦人.

我需要将哪个Gemfile添加到其中,以及它将位于何处?

gem list:
bigdecimal (1.1.0)
childprocess (0.3.9)
commonwatir (4.0.0)
ffi (1.8.1 x86-mingw32)
io-console (0.4.2, 0.3)
json (1.8.0, 1.7.7, 1.5.5)
mini_portile (0.5.0)
minitest (5.0.0, 2.5.1)
multi_json (1.7.3)
rake (10.1.0.beta.3, 10.0.4, 0.9.2.2)
rdoc (4.0.1, 3.9.5)
rubygems-update (2.0.3)
rubyzip (0.9.9)
selenium-webdriver (2.32.1)
watir-webdriver (0.6.4)
websocket (1.0.7)
win32-api (1.4.8 x86-mingw32)
win32-process (0.7.2)
windows-api (0.4.2)
windows-pr (1.2.2)
Run Code Online (Sandbox Code Playgroud)

L2G*_*L2G 10

消息来自multi_jsongem,看起来它可能是一个bug.我建议关注这张GitHub票.

如果消息太令人痛苦,您可以降级multi_json到版本1.6.1以摆脱它.(至少这对我有用.)

更新:

在我看来,问题的根源在于,虽然multi_json想要将其jsonjson_puregems的使用限制为特定版本,但作者multi_json并未gem在其代码中使用该方法来激活这些版本.(听起来他认为Bundler是指定宝石版本的唯一方法;它不是.)

因为multi_json在尝试之前会尝试ojyajl-ruby宝石json,使用其中之一可能是最好的解决方法.所以你可以安装最新的multi_json,然后安装ojyajl-ruby与之一起安装.


Sve*_*lav 5

试试这个:

gem update --system 
gem update
Run Code Online (Sandbox Code Playgroud)