Skip to content

Instantly share code, notes, and snippets.

@darrencauthon
Created March 13, 2016 17:48
Show Gist options
  • Save darrencauthon/e9c9697b7cb555f39ffb to your computer and use it in GitHub Desktop.
Save darrencauthon/e9c9697b7cb555f39ffb to your computer and use it in GitHub Desktop.
Loading a gem via IRB
# https://github.com/banzsolt/wargaming_api/
wargaming_api git:(master) bundle exec irb
2.0.0-p647 :001 > WargamingApi::Accounts
NameError: uninitialized constant WargamingApi::Accounts
from (irb):1
from /Users/darrencauthon/.rvm/rubies/ruby-2.0.0-p647/bin/irb:12:in `<main>'
2.0.0-p647 :002 > require_relative 'lib/wargaming_api'
accounts -> Players loaded.
accounts loaded.
=> true
2.0.0-p647 :003 > WargamingApi::Accounts
=> WargamingApi::Accounts
2.0.0-p647 :004 >
@darrencauthon
Copy link
Author

When you run:

bundle exec irb

It's no different than running irb alone... except that bundler will load all of the gems in your Gemfile.

But what about the most important gem of all, the one you are working on?

Well, bundler won't load that, but if you organize your gem code properly you'll be able to include all of the files in your gem with one single require or require_relative call. That file is the the single ruby file in the /lib folder.

@banzsolt
Copy link

I see now.

So the way to fix this is to run: require_relative 'lib/wargaming_api' every time when I am debugging?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment