[Rubygems-developers] Question on GEM_PATH

Martin Krauskopf martin.krauskopf at gmail.com
Thu Jan 24 04:56:30 EST 2008

Eric Hodel wrote:
> On Jan 23, 2008, at 04:24 AM, Martin Krauskopf wrote:
>> Hi, reviving little old thread,
>> I've noticed the automatic repository creation on demand. My  
>> question is
>> whether there is an 'official' way to initialize/create a new  
>> repository
>> 'just now', without waiting for a 'demand'.
>> My use-case is that in the IDE I'll let user adjust a GEM_PATH. Ff the
>> user enter a non-existing or empty repository, I'll show the dialog
>> saying something like:
>>   "The directory is not a valid RubyGems repository, do you want to  
>> set
>>    it up?"  [Yes] [No]
>> If 'Yes' what should I run? I tried just a 'gem env' and it will
>> create/setup gems repositories in all non-repository directories on  
>> the
>> So may I rely on 'gem env' or is there a more correct way?
> Gem.ensuregem_subdirectories

Thanks Eric,

the method is probably usable (== public) since 1.0.x(?) (I haven't take 
a look into the history). I need to be backward compatible with at least 
Probably I'll use a workaround like:

   module Gem; class << self; public :ensure_gem_subdirectories; end; end
   Gem.ensure_gem_subdirectories '/new/gem/repo'

which should work for 0.9.x as well.

Thanks for the tip,


More information about the Rubygems-developers mailing list