Friday, August 04, 2006

JSON has a colon problem

This fix wasn't working for me. (too easy?)
So I fixed it myself!

The problem:
You install JSON, and try to run the juggernaut push server, and think everything's gonna be cool... but then:

[pboling@host my_app]$ sudo gem install json
Successfully installed json-0.4.1
Installing ri documentation for json-0.4.1...

lib/json/editor.rb:977:50: ':' not followed by identified or operator
Installing RDoc documentation for json-0.4.1...

lib/json/editor.rb:977:50: ':' not followed by identified or operator

And get more baffling errors...

[pboling@host my_app]$ ruby script/push_server
script/push_server:37:in `require': no such file to load -- json (LoadError)
from script/push_server:37


So you fix them!

[pboling@host my_app]$ cd /usr/lib/ruby/gems/1.8/gems/
(Some systems may be /usr/local/lib... or something else)


All of your installed gems should be sitting here:

[pboling@host gems]$ ls
actionmailer-1.2.3 activerecord-1.14.3 json-0.4.1 rails-1.1.4 actionpack-1.12.3 activesupport-1.3.1 mysql-2.7 rake-0.7.1 sources-0.0.1
actionwebservice-1.1.4 fcgi-0.8.7 rubygems-update-0.9.0

[pboling@host gems]$ cd json-0.4.1/lib/json/


There's the offending editor.rb file!

[pboling@host json]$ ls
Array.xpm FalseClass.xpm json.xpm NilClass.xpm String.xpm
editor.rb Hash.xpm Key.xpm Numeric.xpm TrueClass.xpm


Edit it and remove the offending colon:

[pboling@host json]$ sudo vi editor.rb +977

Change this:

@treeview.signal_connect(:'cursor-changed') do

to this (delete colon):

@treeview.signal_connect('cursor-changed') do

and save... (:wq)


[pboling@host json]$ cd ../../


There's the install file!

[pboling@host json-0.4.1]$ ls
bin GPL lib linecover.db README TODO
CHANGES install.rb linecover_config.rb Rakefile tests VERSION


Run the install file:

[pboling@host json-0.4.1]$ sudo ruby install.rb


It will do this:

cd bin
install -c edit_json.rb /usr/bin
cd -
cd lib
install -c json.rb /usr/lib/site_ruby/1.8
mkdir -p /usr/lib/site_ruby/1.8/json
install -c json/editor.rb /usr/lib/site_ruby/1.8/json
install -c json/json.xpm /usr/lib/site_ruby/1.8/json
cd -


Then start your Juggernaut push_server:

[pboling@host igacc]$ ruby script/push_server
Starting server...
Server is on...
IP: 0.0.0.0
Port: 3100
Computer Name: 0.0.0.0
Allowed IP for rails:
Serving...


And you are now much more awesome than you were 2 minutes ago!

7 hashings:

Zimm said...

Does anyone else reading this understand what just happened? Am I completely out of touch?

Galtzo said...

It's a lot more likely that you're the only one reading it. ;) Really I posted it here so I would remember how I fixed it later, and becaue I saw another guy had the same problem on a mailing list I subscribe to...

Flornet said...

thanks for the help man !

Galtzo said...

Your welcome! I'm glad someone besides myself found it useful!

Anonymous said...

It worked for me too, with json 0.4.2

Ben Gotow said...

This is sort of a big deal, no? It seems like they would have fixed it by 0.4.2... Oh well. Thanks a ton! I'm bookmarking this.

Galtzo said...

I am glad it is still working with 0.4.2. Unfortunately that means it still has not been fixed in the source. :( I ended up not using JSON at all after fixing it, so I am glad that others are getting use out of this writeup! I may look into JSON again for some sites I plan on doing in the future...
Anyone may feel free to report this bug, as I have not, nor would I know where to go to do so, nor do I have time. I never actually used JSON beyond an initial flirtation with it. Happy coding!

This blog began on Monday, September 27, 2004.
Hits since 2/20/2007:
free hit counters
free hit counters