From: Bernard Lambeau Date: 2011-01-14T23:26:49+09:00 Subject: Re: Best practice to require external code dependency ? --0015175cdef297d31f0499cf2001 Content-Type: text/plain; charset=ISO-8859-1 I see (I was currently re-reading https://gist.github.com/54177, which is clear in fact -- my apologies). I understand that users of my library will have a good _foo_ executable that works fine :-) Now, as a developer I would like to be able to run (no rake, no rspec, and so on): ruby -rrubygems bin/foo How are version requirements met in that scenario? I assume they are not and that rubygems will load last versions of all gems? Should I configure rvm's gemsets on my devel computer ? or do you use Bundler to manage that case ?? Thanks again for clarification! B On Fri, Jan 14, 2011 at 3:10 PM, Luis Lavena wrote: > 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 > > --0015175cdef297d31f0499cf2001--