On Wed, 19 Jul 2006, stu wrote:

> what needs to be done with the one click installer is not have it assume its
> on the system that built it. it would be nice, if there was a generic config
> that could be changed so MAKE=nmake.exe and CC=cl.exe that overrides
> whatever ruby is assuming...

i've posted this as long as a year ago - but here's a simple patch to the
'gem' command that allows exactly this.  usage is like

   gem install bindir=/my/bin/dir/bin foobar

also, note that if you're ever installing via install.rb or setup.rb you can
always clobber rbconfig values in place using something like

   ruby -r rbconfig -e'  Config::CONFIG["KEY"] = "VAL";  load ARGV.shift  '  ./install.rb


here's the patched gem command:


#!/usr/bin/env ruby

require 'rubygems'
Gem.manage_gems

required_version = Gem::Version::Requirement.new(">= 1.8.0")
unless  required_version.satisfied_by?(Gem::Version.new(RUBY_VERSION))
   puts "Expected Ruby Version #{required_version}, was #{RUBY_VERSION}"
   exit(1)
end

# We need to preserve the original ARGV to use for passing gem options
# to source gems.  If there is a -- in the line, strip all options after
# it...its for the source building process.
args = !ARGV.include?("--") ? ARGV.clone : ARGV[0...ARGV.index("--")]

#
# munge rbconfig from any command line or environment kv pair
#
kvs = []
re = %r/^ \s* ([^=\s]+) \s* = \s* ([^\s]+) \s* $/x
args.delete_if{|arg| (m = re.match(arg)) and (kvs << m.to_a.last(2))}
ENV::each{|k,v| (k =~ %r/^GEM_/) and (kvs << [k.delete('GEM_'), v])}
p kvs
unless kvs.empty?
   require 'rbconfig'
   kvs.each{|k,v| Config::CONFIG[k] = v}
end

Gem::GemRunner.new.run(args)

-a
-- 
suffering increases your inner strength.  also, the wishing for suffering
makes the suffering disappear.
- h.h. the 14th dali lama