On Sat, 20 Mar 2004 05:07:55 +0100, Simon Strandgaard <neoneye / adslhome.dk> wrote: > I think I have prepared my package for rubygems, > however I have no clue how to require it. > > http://rubyforge.org/download.php/435/iterator-0.5.gem > > > I have tried > > server> ruby concat1.rb > concat1.rb:1:in `require': No such file to load -- iterator (LoadError) > from concat1.rb:1 > server> pwd > /usr/home/neoneye/stow/ruby/lib/ruby/gems/1.8/iterator-0.5/samples > server> expand -t2 concat1.rb > require 'iterator' I think that you have to do require 'rubygems' require_gem 'iterator' ....and then use the library as you normally would. I had hoped the RubyGems overloaded "require" in a clever way so that you could just require 'iterator' and not have to worry about whether iterator is installed as a Gem or as a "normal" package. It would be nice if there was something like this in the standard library (perhaps named "rubygems-compat.rb") that was require'd automatically:[1] [Parts of this untested because I have RubyGems installed, but the concept is clear] rubygems_installed = true begin require 'rubygems' rescue LoadError rubygems_installed = false end if rubygems_installed # Backwards compatability alias _old_require require def require(library) begin require_gem(library) rescue LoadError _old_require(library) end end else # Forwards compatability def require_gem(gem, need_version = false) if need_version warn "Version requirement #{need_version} given, unable to guarantee version used." end require(gem) end end [1] The more messing around we do with $LOAD_PATH, the more (IMHO) it looks like it would be nice to have a system-wide "init.rb" that was required automatically when Ruby starts. The default init.rb could look something like this: require 'rubygems-compat' # We should check $SAFE before we do this, of course. homeinit = File.join(ENV["HOME"], ".rubyinit.rb") require homeinit if File.exist?(homeinit) I proposed something like this in the past. I was basically told just to use RUBYOPT, like so: export RUBYOPT="-r$HOME/prog/ruby/init" ...and then put whatever I wanted in ~/prog/ruby/init.rb. This works, but it isn't system-wide, which would be nice for some cases. Whoa, two soapboxen in one post. Better stop now. Jason Creighton