Search code examples
rubybundlerrbenv

Mysterious LoadError on installed gem with bundler


The following terminal session explains the problem. I don't understand how it's possible that I'm getting a load error on an installed gem.

The sailthru gem which isn't loading is something I installed today, which may be relevant. I verified it was installed to the same location as my other gems, and I also tried restarting the Terminal app. I'm using rbenv on a mac. However, I have not installed a new version of ruby for at least a few weeks, and have been using it daily until now without any issues.

Thanks for any help.

$ gem list | grep sailthru
sailthru (1.1.2)
sailthru-client (4.0.1, 2.0.0)
$ cat Gemfile | grep sailthru
gem 'sailthru'
$ cat Gemfile.lock | grep sailthru
    sailthru (1.1.2)
  sailthru
$ bundle exec thin start
Using rack adapter
/Users/jg/Dropbox/sinatra/app.rb:5:in `require': cannot load such file -- sailthru (LoadError)
$ irb
irb(main):001:0> require 'sailthru'
=> true
irb(main):002:0> 

Solution

  • There is no sailthru file to require.

    You should take a look at the project page.

    require 'sailthru'

    should be

    require 'sailthru/client'

    Hope this helps.

    EDIT

    Just noticed the last part where you gave irb output.

    The sailthru.rb file is part of the sailthru-client gem. It is working through irb because irb is not loaded via bundle exec. This means that every gem installed is available in irb.

    To fix this (if you need that sailthru-client gem in your app. Add gem 'sailthru-client' to your gem file. Do a bundle install, then run your bundle exec again.

    You should not see that error after that. Keep in mind. bundle exec only uses gem libraries that are specified in your Gemfile.