Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions lib/rubygems/defaults.rb
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,18 @@ def self.default_cert_path
default_cert_path
end

##
# Enables automatic installation into user directory

def self.default_user_install # :nodoc:
if !ENV.key?("GEM_HOME") && (File.exist?(Gem.dir) && !File.writable?(Gem.dir))
Gem.ui.say "Defaulting to user installation because default installation directory (#{Gem.dir}) is not writable."
return true
end

false
end

##
# Install extensions into lib as well as into the extension directory.

Expand Down
5 changes: 1 addition & 4 deletions lib/rubygems/installer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -684,10 +684,7 @@ def process_options # :nodoc:
# * `true`: `--user-install`
# * `false`: `--no-user-install` and
# * `nil`: option was not specified
if options[:user_install]
@gem_home = Gem.user_dir
elsif options[:user_install].nil? && !ENV.key?("GEM_HOME") && (File.exist?(Gem.dir) && !File.writable?(Gem.dir))
say "Defaulting to user installation because default installation directory (#{Gem.dir}) is not writable."
if options[:user_install] || (options[:user_install].nil? && Gem.default_user_install)
@gem_home = Gem.user_dir
end
end
Expand Down