简体   繁体   English

JSON Ruby 宝石中的错误 - Ubuntu 11.04

[英]Error in JSON Ruby Gem - Ubuntu 11.04

Hello the clever people of Stackoverflow.你好 Stackoverflow 的聪明人。

I am trying to right a little JSON script.我正在尝试纠正一点 JSON 脚本。 But the JSON Gem does not seem to be working.但是 JSON Gem 似乎无法正常工作。 Just by having the code:只需拥有代码:

require 'rubygems' 
require 'json'

I get the error:我得到错误:

./json.rb:5: undefined method `search' for nil:NilClass (NoMethodError)
    from /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
    from /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `require'
    from places.rb:2

I don't have any other code in the file.我在文件中没有任何其他代码。 I have unistalled the gem and reinstalled.我已卸载 gem 并重新安装。 But the same error, I can't find what the problem is?但是同样的错误,我找不到问题是什么?

I feel like all I do on this site is ask for help, but I do only come here as a last resort, and if there is anything I can do please let me know in return我觉得我在这个网站上所做的只是寻求帮助,但我只是在不得已的情况下才来这里,如果有什么我能做的,请让我知道作为回报

Thanks谢谢

Charlie查理

Do you have a json.rb in the same directory as the places.rb ?你有一个json.rb在与places.rb相同的目录吗? Try renaming that to something else.尝试将其重命名为其他名称。

I upgraded to the last Ruby 1.9.2 using RVM and re-installed Gems and its working fine, if anyone runs into the same problem would recommend doing this!我使用 RVM 升级到最后一个 Ruby 1.9.2 并重新安装了 Gems,它工作正常,如果有人遇到同样的问题,建议这样做!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM