Skip to content
Snippets Groups Projects
Commit 5d7911fa authored by Mike McQuaid's avatar Mike McQuaid Committed by GitHub
Browse files

Merge pull request #1028 from penman/install_gems_to_gem_home

Use user GEM_HOME for installing gems
parents 9412c89e 4c773725
No related branches found
No related tags found
No related merge requests found
...@@ -59,6 +59,10 @@ then ...@@ -59,6 +59,10 @@ then
odie "Cowardly refusing to continue at this prefix: $HOMEBREW_PREFIX" odie "Cowardly refusing to continue at this prefix: $HOMEBREW_PREFIX"
fi fi
# Save value to use for installing gems
export GEM_OLD_HOME="$GEM_HOME"
export GEM_OLD_PATH="$GEM_PATH"
# Users may have these set, pointing the system Ruby # Users may have these set, pointing the system Ruby
# at non-system gem paths # at non-system gem paths
unset GEM_HOME unset GEM_HOME
......
...@@ -270,17 +270,24 @@ module Homebrew ...@@ -270,17 +270,24 @@ module Homebrew
end end
def self.install_gem_setup_path!(name, version = nil, executable = name) def self.install_gem_setup_path!(name, version = nil, executable = name)
require "rubygems" # Respect user's preferences for where gems should be installed.
ENV["GEM_HOME"] = ENV["GEM_OLD_HOME"].to_s
ENV["GEM_HOME"] = Gem.user_dir if ENV["GEM_HOME"].empty?
ENV["GEM_PATH"] = ENV["GEM_OLD_PATH"] unless ENV["GEM_OLD_PATH"].to_s.empty?
# Make rubygems notice env changes.
Gem.clear_paths
Gem::Specification.reset
# Add Gem binary directory and (if missing) Ruby binary directory to PATH. # Add Gem binary directory and (if missing) Ruby binary directory to PATH.
path = ENV["PATH"].split(File::PATH_SEPARATOR) path = ENV["PATH"].split(File::PATH_SEPARATOR)
path.unshift(RUBY_BIN) if which("ruby") != RUBY_PATH path.unshift(RUBY_BIN) if which("ruby") != RUBY_PATH
path.unshift("#{Gem.user_dir}/bin") path.unshift("#{Gem.dir}/bin")
ENV["PATH"] = path.join(File::PATH_SEPARATOR) ENV["PATH"] = path.join(File::PATH_SEPARATOR)
if Gem::Specification.find_all_by_name(name, version).empty? if Gem::Specification.find_all_by_name(name, version).empty?
ohai "Installing or updating '#{name}' gem" ohai "Installing or updating '#{name}' gem"
install_args = %W[--no-ri --no-rdoc --user-install #{name}] install_args = %W[--no-ri --no-rdoc #{name}]
install_args << "--version" << version if version install_args << "--version" << version if version
# Do `gem install [...]` without having to spawn a separate process or # Do `gem install [...]` without having to spawn a separate process or
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment