adamscott
adamscott

Reputation: 853

Load File From Local Gem in IRB

I have a cloned a ruby gem to my client.

According to the docs here (https://github.com/Jbur43/usps_counties)

I have to require 'usps_counties' in order to load it.

So my path is /usps_counties. From there I load irb and try requiring the usps_counties file, but it can't find it.

I then go to /usps_counties/lib (the file lives in the lib directory), load irb and try requiring it but cant find it.

What am I doing wrong here?

Upvotes: 5

Views: 3045

Answers (2)

stereoscott
stereoscott

Reputation: 13436

If you want to require a local file or gem in irb, I like this method:

irb -I lib -r usps_countries

This allows you to then require the module in your new irb instance:

require 'usps_countries'

Options used:

-I path           Specify $LOAD_PATH directory
-r load-module    Same as `ruby -r'

Upvotes: 9

BullsEye72
BullsEye72

Reputation: 11

Have you tried a relative path?

require './usps_counties'

require_relative 'usps_counties'

Upvotes: 1

Related Questions