Chiggins Chiggins - 10 months ago 57
Ruby Question

Importing and working with a ruby gem

My title might not accurately reflect what I'm trying to ask, but it's the best that I could come up with really.

What I'm trying to do is make modifications to a library, and to test those modifications in a project. So I've got RVM running, a project folder called

, a gemset with 2.3.1, and the library git cloned into the folder
. I have a file
which has this line in it:

gem "metasm", :path => "metasm"

And when I run
bundle install
I get the following:

Using metasm 1.0.2 from source at `metasm`
Using bundler 1.13.6
Bundle complete! 1 Gemfile dependency, 2 gems now installed.
Use `bundle show [gemname]` to see where a bundled gem is installed.

Good, so everything seems to work as it should. Awesome. I drop down into
and go to
the library/gem, but it doesn't seem to work too well for me.

2.3.1 :001 > require "metasm"
LoadError: cannot load such file -- metasm
from /home/chiggins/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /home/chiggins/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from (irb):1
from /home/chiggins/.rvm/rubies/ruby-2.3.1/bin/irb:11:in `<main>'

Now here's what I'm not really understanding. Why can I not use
from where it currently is at, even though
bundle install
worked as it should?

This was the best way I thought that this would work. What I ideally want to do is be able to make my changes to the
library as I see fit and either run
or a Ruby script to test/validate my changes. Is this a good way to go about it or should I go about it another way?

Thanks for any help!

Answer Source

You must enter irb using the bundle exec irb command.

As you can see here, the bundle exec <command> executes the command making all gems specified in the Gemfile available to require in Ruby programs.