Reputation: 45074
I have a tiny, plain (i.e. non-Rails) Ruby project that I'm trying to get to work with the addressable
gem. Here's what happens:
$ ruby -r rubygems sign.rb
sign.rb:5:in `require': cannot load such file -- addressable (LoadError)
from sign.rb:5:in `<main>'
This is the Gemfile
:
source "http://rubygems.org"
gem "addressable", "~> 2.3.2"
This is sign.rb
:
#!/usr/bin/env ruby
require "rubygems"
require "bundler/setup"
require "addressable"
That's all there is to it. Why doesn't it want to use the gem?
Upvotes: 1
Views: 1722
Reputation: 79723
There is no addressable
file that you can require, just the addressable
directory. You need to require the specific file under that directory you want, e.g.:
require 'addressable/uri'
uri = Addressable::URI.parse("http://example.com/path/to/resource/")
# etc ...
or
require "addressable/template"
template = Addressable::Template.new("http://example.com/{?query*}/")
# etc...
Check out the addressable
docs.
Upvotes: 2
Reputation: 2103
Have you installed the gem previously by using $ bundle install
?
This will fetch the gems specified in your Gemfile and make them available to the working directory.
Upvotes: 0