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?
To install a gem, use gem install [gem] . Browsing installed gems is done with gem list . For more information about the gem command, see below or head to RubyGems' docs. There are other sources of libraries though.
A Gemfile describes the gem dependencies required to execute associated Ruby code. Place the Gemfile in the root of the directory containing the associated code. For instance, in a Rails application, place the Gemfile in the same directory as the Rakefile .
A Gemfile is a file that is created to describe the gem dependencies required to run a Ruby program. A Gemfile should always be placed in the root of the project directory.
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'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With