You are using an old or stdlib version of json gem
Asked Answered
B

4

11

I've seen the following issue mentioned in another thread a few days ago amongst other problems, but the solution for this issue (to me) didn't seem to be addressed.

I recently ran a test on my Ruby 1.9.2-p290 environment and was presented with the following error when I ran a test script:

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'

This issue continued when I created a completely fresh Ruby 1.9.3-p392 environment, running on Windows XP (don't ask). What confuses me is that even when I have json 1.7.7 or 1.8.0 installed (gem list is pasted below), I still get this message when I run my test. It's not really affecting my test results, but the warning is just rather annoying to see each time.

Which Gemfile do I need to add this version into, and where would it be located?

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)
Bybidder answered 14/5, 2013 at 12:52 Comment(3)
Aside: I have seen the same behavior in Ruby 1.9.3-p392. Also note that this warning comes up even in environments where Bundler is not in use, so the suggestion to edit Gemfile is not applicable.Gallium
the suggestion regarding the gemfile is obviously some other gem developer thinking that 'surely everyone uses bundler'Acervate
Or "surely everyone uses rvm"... or "surely everyone uses Linux"... or "surely everyone uses a terminal that understands ANSI escape codes"... Sigh.Gallium
G
10

The message is coming from the multi_json gem, and it seems like it could be a bug. I suggest keeping an eye on this GitHub ticket.

If the message is too distressing, you can downgrade multi_json to version 1.6.1 to get rid of it. (At least this works for me.)

UPDATE:

It looks to me like the root of the problem is that while multi_json wants to limit its use of the json and json_pure gems to specific versions, the author of multi_json isn't using the gem method in his code to activate these versions. (It sounds like he thinks Bundler is the only way to specify versions of gems; it isn't.)

Since multi_json will try the oj and yajl-ruby gems before it tries json, using one of those may be the best workaround of all. So you can just install the latest multi_json and then install either oj or yajl-ruby along with it.

Gallium answered 16/5, 2013 at 1:21 Comment(4)
Indeed, a post on the Watir Google Group suggested downgrading multi_json to 1.7.2; this certainly worked for me. (groups.google.com/group/watir-general/browse_thread/thread/…)Bybidder
"(It sounds like he thinks Bundler is the only way to specify versions of gems; it isn't.)" +1 for that.. His suggestion in the error message relative to altering a gemfile is more evidence of that sort of thinking.Acervate
I'm running a regular ruby script (i.e. not rails) and hit the error. By installing the 'oj' gem, the error went away for me.Infusionism
I've both oj and yajl-ruby installed. But I do still get the message when issuing vagrant commands. My vagrant version is 1.3.3. Why I m getting this message?Roswald
A
5

Try this:

gem update --system 
gem update
Anking answered 14/5, 2013 at 21:38 Comment(0)
S
1

Go to your Ruby installation path, for example, C:\Ruby192\lib\ruby\1.9.1\json

Open version.rb file and update the version detail as shown bellow: VERSION = '1.7.7'

Selma answered 17/5, 2013 at 6:1 Comment(0)
K
0

Try running your tests with the bundle exec command. This will force your environment to use the gems in Gemfile.lock.

Kresic answered 15/5, 2013 at 10:54 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.