When I try to include a library on the command line, I receive LoadError messages
$ ruby -v
ruby 1.8.7 (2012-06-29 patchlevel 370)
$ gem list | grep coderay_bash
coderay_bash (1.0.2)
$ ruby -rcoderay_bash /bin/coderay -v
ruby: no such file to load -- coderay_bash (LoadError)
$ ruby -rubygems -rcoderay_bash /bin/coderay -v
ruby: no such file to load -- coderay_bash (LoadError)
It looks to work with ruby 1.9.2
$ ruby -v
ruby 1.9.2p290 (2011-07-09)
$ ruby -rcoderay_bash /bin/coderay -v
CodeRay 1.0.7
In Ruby 1.8, anything you want to
requirethat was installed with RubyGems cannot be accessed until yourequire 'rubygems'. 1.9 removes this requirement.You have several options for this:
require 'rubygems'at the top of your file. This is harmless for 1.9 and is probably the easiest thing, because it’s in the code and no one using your app has to remember anything#!/usr/bin/env ruby -rubygemsThis tells the Ruby interpreter to require rubygems, but allows users to avoid this by sending your file torubydirectly, if they are offended by RubyGems for some reasonrubyand use-rubygems, e.g.ruby -rubygems my_app.rbThis has no dependencies on RubyGems in your code, and will work, but you have to remember to do it everytime, which is somewhat of a pain.