Ruby not recognising gems from local source, included in Gemfile


I've had some trouble with gems from a local source before, so set up a simple test project. I haven't had simple-rss installed before. This is my Gemfile:

source ''

gem 'simple-rss', :path => '~/code/simple-rss'

I then run bundle install, it tells me:

Using simple-rss 1.2.3 from source at `~/code/simple-rss`
Using bundler 1.12.4
Bundle complete! 1 Gemfile dependency, 2 gems now installed.

So then I make test.rb in the same folder as the Gemfile. The test.rb file only has the require right now:

require 'simple-rss'

I run ruby test.rb, and get this error:

/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- simple-rss (LoadError)
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from test.rb:1:in `<main>'

So that's the first evidence of a problem. I then do:

sudo gem install simple-rss

That successfully installs it. I do ruby test.rb again, and get no issues. So it's able to run the gem from the original source once it's been installed with gem install, but not from the local source after running with Bundler.

Show source
| ruby   | rubygems   | bundler   | gemfile   2016-07-17 14:07 1 Answers

Answers ( 1 )

  1. 2016-07-17 14:07

    If you want to use the gems dictated in your Gemfile, I suggest prefixing your commands with bundle exec, eg. bundle exec ruby test.rb. Otherwise your Ruby will not know about them.

◀ Go back