Run the installer from ruby instead of using system(); otherwise we risk running the wrong ruby

This commit is contained in:
Jordan Sissel 2012-11-06 17:07:15 -08:00
parent 3142af0c19
commit a3b8d6db43

View file

@ -1,6 +1,7 @@
#!/usr/bin/env ruby
require "rubygems/package"
require "rubygems/specification"
require "rubygems/commands/install_command"
gemspec = ARGV.shift
@ -11,13 +12,21 @@ deps = [spec.development_dependencies, spec.runtime_dependencies].flatten
target = "vendor/bundle/jruby/1.9/"
deps.each do |dep|
cmd = "gem install --install-dir #{target} #{dep.name} -v '#{dep.requirement}'"
puts cmd
system(cmd)
#cmd = "gem install --install-dir #{target} #{dep.name} -v '#{dep.requirement}'"
installer = Gem::Commands::InstallCommand.new
installer.options[:generate_rdoc] = false
installer.options[:generate_ri] = false
installer.options[:version] = dep.requirement
installer.options[:args] = [dep.name]
begin
installer.execute
rescue Gem::SystemExitException => e
if e.exit_code != 0
puts "Installation of #{dep.to_s} failed"
raise
end
end
end
#specs_and_sources, errors = Gem::SpecFetcher.fetcher.fetch_with_errors(deps.first, true, true, false)
#require "pry"; binding.pry