File tree Expand file tree Collapse file tree 2 files changed +13
-4
lines changed Expand file tree Collapse file tree 2 files changed +13
-4
lines changed Original file line number Diff line number Diff line change @@ -235,6 +235,18 @@ def self.default_cert_path
235235 default_cert_path
236236 end
237237
238+ ##
239+ # Enables automatic installation into user directory
240+
241+ def self . default_user_install # :nodoc:
242+ if !ENV . key? ( "GEM_HOME" ) && ( File . exist? ( Gem . dir ) && !File . writable? ( Gem . dir ) )
243+ Gem . ui . say "Defaulting to user installation because default installation directory (#{ Gem . dir } ) is not writable."
244+ return true
245+ end
246+
247+ false
248+ end
249+
238250 ##
239251 # Install extensions into lib as well as into the extension directory.
240252
Original file line number Diff line number Diff line change @@ -684,10 +684,7 @@ def process_options # :nodoc:
684684 # * `true`: `--user-install`
685685 # * `false`: `--no-user-install` and
686686 # * `nil`: option was not specified
687- if options [ :user_install ]
688- @gem_home = Gem . user_dir
689- elsif options [ :user_install ] . nil? && !ENV . key? ( "GEM_HOME" ) && ( File . exist? ( Gem . dir ) && !File . writable? ( Gem . dir ) )
690- say "Defaulting to user installation because default installation directory (#{ Gem . dir } ) is not writable."
687+ if options [ :user_install ] || ( options [ :user_install ] . nil? && Gem . default_user_install )
691688 @gem_home = Gem . user_dir
692689 end
693690 end
You can’t perform that action at this time.
0 commit comments