J’essayais twitter4r, une librairie pour accéder à l’API twitter depuis Ruby, avec une installation Ruby sous Windows (Vista) et je me heurtais au problème suivant:
Mon serveur crashait avec une “Segmentation Fault” dans json/common.rb.
Plus spécifiquement, c’est au moment de l’appel de la méthode timeline_for que mon serveur partait dans les roses.
J’ai trouvé la solution au problème ici, mais comme c’est un article en Japonais, je me disais que ça pourrait faire plaisir à certains que je traduise.
En fait, c’est assez simple, le problème vient de la librairie json, dont dépend twitter4r. Si on installe twitter4r avec gem, comme indiqué sur le site, la librairie json est également installée, mais les binaires Win32 sont bogués. Heureusement, il existe une implémentation “pure ruby” de json, et c’est celle-la qu’il faut installer. Le problème est que si on l’installe avec gem, elle n’est pas reconnue. La solution est donc d’installer manuellement json et twitter4r.
Ca marche comment?
- Pour json, on downloade le package
json_puresur RubyForge, on le décompresse quelque part, on va dans le répertoirejson_pure-x.y.zet on exécute:ruby install.rbdans une console. - Pour twitter4r, on downloade le package
twitter4rtoujours sur RubyForge, on le décompresse quelque part, on va dans le répertoiretwitter4r-x.y.z\libet on copie le répertoiretwitteret le fichiertwitter.rbdans le répertoire de librairies de ruby (taper la commanderuby -e 'puts $:'pour avoir une liste).
Et voilà!I was giving a try to twitter4r, a library for accessing Twitter’s API in Ruby, with Ruby installed on a Windows (Vista) box, and I was facing a the following problem:
My RoR server was crashing with “Segmentation Fault” somewhere in json/common.rb.
More specifically, it is when calling the timeline_for method that my server was blowing up.
I found the solution to this problem here, but since it is in Japanese, I thought some of you might be happy if I’d translate it in English.
In fact, it’s quite simple: the problem comes form the json library, on which twitter4r depends. If you install twitter4r with gem, as mentioned in their website, the json library is also installed, but the Win32 binaries seem buggy. The good news is there also exists a “pure ruby” implementation of json, and this one works fine. The problem is, if you install it with gem, it won’t be recognized. The solution is therefore to install both json and twitter4r manually.
How do I do that?
- For json, download
json_purepackage on RubyForge, uncompress it somewhere, move to thejson_pure-x.y.zdirectory and type the following command in a console:ruby install.rb. - As for twitter4r, download the
twitter4rpackage also on RubyForge, uncompress it somewhere, go to thetwitter4r-x.y.z\libdirectory and copy both thetwitterdirectory andtwitter.rbfile in Ruby’s library directory (type thisruby -e 'puts $:'to get the list).
Voilà!