Today I started studing the Evernote Api for a new project.
The first thing after reading the website was searching for the gem that provide a wrapper over the Thrift interface of Evernote.
Simple and easy, just add the gem to the Gemfile, bundle install and write a small piece of code inside the project to test api key
Nobody ever said life was easy… The program exit with and error
1.9.3-p0/lib/ruby/gems/1.9.1/gems/thrift-0.8.0/lib/thrift/transport/http_client_transport.rb:47:in `initialize': can't convert nil into String (TypeError)
WTF? The error seems to be in the Thrift gem… Let’s start searching on Google. Nobody seems to have the same problem, it must be my fault! Then the idea… Try with another ruby version, I use rbenv to change my ruby version… 1.8.7… No error!
Some Google digging later I find that the problem is with enconding in the new Ruby. A fork of Thrift with the fix is on Github. Good!
Another test and another error: cannot change encoding on frozen String! This seems simple, let’s add a dup on the string… and Done!
Now the example work again with ruby 1.9.3-p0 and 1.9.3-p125
How I make the change? I fork the github project, make the fix and do a pull request… No way! Thrift Github repo contains code for a lot of languages, and I can’t understand how to specify in bundle how to use it!
The idea… “RECREATE ALL THE PRJECTS”. Long story short I’ve recreated the repo for the project. To get yourself up and running without hassle add this to your Gemfile:
gem "evernote", "~> 1.2.0", :git => "git://github.com/McRipper/evernote.git" gem "thrift", :git => "git://github.com/McRipper/thrift-1.9.3.git" gem "thrift_client", "~> 0.8.1", :git => "git://github.com/McRipper/thrift_client.git"
I wrote this post to share with the community the hours I’ve spent figuring out this mess. The solution is very ugly and quick, but I think that in the future the various gems will be fixed and this hack can be removed!