Skip to content

Commit

Permalink
Allow --install-dir to be specified together with --user-install
Browse files Browse the repository at this point in the history
The combination of `install-dir` and `--user-install` used to be
disabled for no good reason. This even makes problem on Linux
distributions such as Fedora, where `--user-install` is set by default
via operating_system.rb.

The `--install-dir` is already prefered over the `--user-install` by
the implementation, therefore just drop the check.
  • Loading branch information
voxik committed Oct 24, 2023
1 parent ff25225 commit b581da1
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 23 deletions.
8 changes: 0 additions & 8 deletions lib/rubygems/commands/install_command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -136,13 +136,6 @@ def usage # :nodoc:
"#{program_name} [options] GEMNAME [GEMNAME ...] -- --build-flags"
end

def check_install_dir # :nodoc:
if options[:install_dir] && options[:user_install]
alert_error "Use --install-dir or --user-install but not both"
terminate_interaction 1
end
end

def check_version # :nodoc:
if options[:version] != Gem::Requirement.default &&
get_all_gem_names.size > 1
Expand All @@ -162,7 +155,6 @@ def execute

ENV.delete "GEM_PATH" if options[:install_dir].nil?

check_install_dir
check_version

load_hooks
Expand Down
15 changes: 0 additions & 15 deletions test/rubygems/test_gem_commands_install_command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -436,21 +436,6 @@ def test_execute_nonexistent_with_dashes
assert_equal expected, output
end

def test_execute_conflicting_install_options
@cmd.options[:user_install] = true
@cmd.options[:install_dir] = "whatever"

use_ui @ui do
assert_raise Gem::MockGemUi::TermError do
@cmd.execute
end
end

expected = "ERROR: Use --install-dir or --user-install but not both\n"

assert_equal expected, @ui.error
end

def test_execute_prerelease_skipped_when_no_flag_set
spec_fetcher do |fetcher|
fetcher.gem "a", 1
Expand Down

0 comments on commit b581da1

Please sign in to comment.