From: Luis Lavena Date: 2011-01-14T23:10:20+09:00 Subject: Re: Best practice to require external code dependency ? On Jan 14, 11:02 am, Bernard Lambeau wrote: > * What if I have a bin/foo executable? Should I make something special there > if I have version requirements on external libs ?? > Actually no. RubyGems will wrap your bin/foo script with a loader that looks like this: require 'rubygems' version = ">= 0" if ARGV.first =~ /^_(.*)_$/ and Gem::Version.correct? $1 then version = $1 ARGV.shift end gem 'mygem', version load Gem.bin_path('mygem', 'foo', version) So your foo script don't need to require rubygems. And when developing, if you run through rspec, it will already load rubygems for you. If you want to test from the command line, then you can: ruby -rrubygems -Ilib bin/foo Or simple put RUBYOPT=-rrubygems and have ruby -Ilib bin/foo So, under your environment will have rubygems and nowhere in your code. -- Luis Lavena