Skip to content
Closed
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
9 changes: 7 additions & 2 deletions lib/rubygems/commands/install_command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ def initialize
:without_groups => [],
})

if !File.writable?(Gem.paths.home)
defaults.merge!({:user_install => true})
end

super 'install', 'Install a gem into the local repository', defaults

add_install_update_options
Expand All @@ -43,8 +47,9 @@ def arguments # :nodoc:
end

def defaults_str # :nodoc:
"--both --version '#{Gem::Requirement.default}' --document --no-force\n" +
"--install-dir #{Gem.dir} --lock"
"--both --version '#{Gem::Requirement.default}' --no-force\n" +
"--install-dir #{Gem.dir} --lock\n" +
install_update_defaults_str
end

def description # :nodoc:
Expand Down
12 changes: 10 additions & 2 deletions lib/rubygems/commands/update_command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,16 @@ class Gem::Commands::UpdateCommand < Gem::Command
attr_reader :updated # :nodoc:

def initialize
super 'update', 'Update installed gems to the latest version',
options = {
:document => %w[rdoc ri],
:force => false
}

if !File.writable?(Gem.paths.home)
options.merge!({:user_install => true})
end

super 'update', 'Update installed gems to the latest version', options

add_install_update_options

Expand Down Expand Up @@ -51,7 +58,8 @@ def arguments # :nodoc:
end

def defaults_str # :nodoc:
"--document --no-force --install-dir #{Gem.dir}"
"--no-force --install-dir #{Gem.dir}\n" +
install_update_defaults_str
end

def description # :nodoc:
Expand Down
6 changes: 5 additions & 1 deletion lib/rubygems/install_update_options.rb
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,11 @@ def add_install_update_options
# Default options for the gem install command.

def install_update_defaults_str
'--document=rdoc,ri --wrappers'
default_args = '--document=ri --wrappers'
if !File.writable?(Gem.paths.home)
default_args += ' --user-install'
end
default_args
end

end