Method: Autoproj::Ops::Install.guess_gem_program

Defined in:
lib/autoproj/ops/install.rb

.guess_gem_programObject

Raises:

  • (ArgumentError)


241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
# File 'lib/autoproj/ops/install.rb', line 241

def self.guess_gem_program
    ruby_bin = RbConfig::CONFIG["RUBY_INSTALL_NAME"]
    ruby_bindir = RbConfig::CONFIG["bindir"]

    candidates = ["gem"]
    candidates.unshift "gem#{$1}" if ruby_bin =~ /^ruby(.+)$/

    candidates.each do |gem_name|
        if File.file?(gem_full_path = File.join(ruby_bindir, gem_name))
            return gem_full_path
        end
    end
    raise ArgumentError, "cannot find a gem program "\
                         "(tried #{candidates.sort.join(', ')} in #{ruby_bindir})"
end