Skip to content

Instantly share code, notes, and snippets.

@godfat
Created November 9, 2014 11:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save godfat/c232d34a86246ca3e3f4 to your computer and use it in GitHub Desktop.
Save godfat/c232d34a86246ca3e3f4 to your computer and use it in GitHub Desktop.
# slow as hell:
require 'rubygems/gem_runner'
Gem::GemRunner.new.run(['install', gem_path])
# fast!
require 'rubygems/commands/install_command'
# read ~/.gemrc
Gem.use_paths(Gem.configuration[:gemhome], Gem.configuration[:gempath])
Gem::Command.extra_args = Gem.configuration[:gem]
# setup install options
cmd = Gem::Commands::InstallCommand.new
cmd.handle_options([])
# install
install = Gem::Installer.new(gem_path, cmd.options)
install.install
puts "\e[35mGem installed: \e[33m#{strip_path(install.gem_dir)} \e[0m"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment