Search code examples
rubyrubygemsrakebundlerrake-task

Everything crashes when I use "bundle exec"


I'm making a gem, and I added a Gemfile to my repository. When I run

$ rake test

Everything goes fine. The test command I wrote myself, and it just executes all the tests in my test folder. So, something like this

ruby -Ilib *_test.rb

But, when I prefix the rake test command with bundle exec, I start getting errors from the only gem I use, faraday. Do you know what could be the problem? (I'm using rbenv)

All of the errors are of this kind:

Flickrie::Error: Flickrie::Error
/Users/jstojanovski/Projects/flickrie/lib/flickrie/client.rb:37:in `on_complete'
/Users/jstojanovski/.rbenv/versions/1.9.2-p318/lib/ruby/gems/1.9.1/gems/faraday-0.7.6/lib/faraday/response.rb:9:in `block in call'
/Users/jstojanovski/.rbenv/versions/1.9.2-p318/lib/ruby/gems/1.9.1/gems/faraday-0.7.6/lib/faraday/response.rb:62:in `on_complete'
/Users/jstojanovski/.rbenv/versions/1.9.2-p318/lib/ruby/gems/1.9.1/gems/faraday-0.7.6/lib/faraday/response.rb:8:in `call'
/Users/jstojanovski/.rbenv/versions/1.9.2-p318/lib/ruby/gems/1.9.1/gems/faraday-0.7.6/lib/faraday/response.rb:8:in `call'
/Users/jstojanovski/.rbenv/versions/1.9.2-p318/lib/ruby/gems/1.9.1/gems/faraday-0.7.6/lib/faraday/response.rb:8:in `call'
/Users/jstojanovski/.rbenv/versions/1.9.2-p318/lib/ruby/gems/1.9.1/gems/faraday-0.7.6/lib/faraday/request/json.rb:32:in `call'
/Users/jstojanovski/.rbenv/versions/1.9.2-p318/lib/ruby/gems/1.9.1/gems/faraday-0.7.6/lib/faraday/request/url_encoded.rb:14:in `call'
/Users/jstojanovski/.rbenv/versions/1.9.2-p318/lib/ruby/gems/1.9.1/gems/faraday-0.7.6/lib/faraday/connection.rb:210:in `run_request'
/Users/jstojanovski/.rbenv/versions/1.9.2-p318/lib/ruby/gems/1.9.1/gems/faraday-0.7.6/lib/faraday/connection.rb:93:in `get'
/Users/jstojanovski/Projects/flickrie/lib/flickrie/client.rb:44:in `get'
/Users/jstojanovski/Projects/flickrie/lib/flickrie/client.rb:85:in `get_licenses'
/Users/jstojanovski/Projects/flickrie/lib/flickrie.rb:72:in `get_licenses'
/Users/jstojanovski/Projects/flickrie/test/license_test.rb:22:in `test_get_licenses'

Here Flickrie::Error is just something I raise whenever an exception is raised during a GET request (I'm making GET requests on the Flickr API).

These errors also occur when I'm running the normal rake test with different ruby versions (different from 1.9.3).


Solution

  • I figured it out. I need to add activesupport to the Gemfile, because faraday uses it without telling you. On older versions of ruby you need to use the ~> 2.3.8 version. This is just a development dependency.