summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHiroshi SHIBATA <hsbt@ruby-lang.org>2024-04-18 15:38:00 +0900
committergit <svn-admin@ruby-lang.org>2025-10-28 11:06:16 +0000
commitd67aba8a5d81383880e05504de9a52ab6b2a015e (patch)
tree2136ddda39d31ac81589f037178b3e7c26fb344e
parent523474bdfcae518ff74d2455f5199ea1df0af760 (diff)
[ruby/rubygems] Completely removed install_as_default feature
https://github.com/ruby/rubygems/commit/15e46a3a68
-rw-r--r--lib/rubygems/commands/install_command.rb6
-rw-r--r--lib/rubygems/commands/setup_command.rb1
-rw-r--r--lib/rubygems/dependency_installer.rb3
-rw-r--r--lib/rubygems/install_default_message.rb13
-rw-r--r--lib/rubygems/install_update_options.rb1
-rw-r--r--lib/rubygems/installer.rb31
-rw-r--r--test/rubygems/helper.rb2
-rw-r--r--test/rubygems/test_gem_installer.rb113
8 files changed, 10 insertions, 160 deletions
diff --git a/lib/rubygems/commands/install_command.rb b/lib/rubygems/commands/install_command.rb
index 2888b6c55a..70d32013ba 100644
--- a/lib/rubygems/commands/install_command.rb
+++ b/lib/rubygems/commands/install_command.rb
@@ -239,11 +239,7 @@ You can use `i` command instead of `install`.
# Loads post-install hooks
def load_hooks # :nodoc:
- if options[:install_as_default]
- require_relative "../install_default_message"
- else
- require_relative "../install_message"
- end
+ require_relative "../install_message"
require_relative "../rdoc"
end
diff --git a/lib/rubygems/commands/setup_command.rb b/lib/rubygems/commands/setup_command.rb
index 85e28ccedd..2b9c522a6b 100644
--- a/lib/rubygems/commands/setup_command.rb
+++ b/lib/rubygems/commands/setup_command.rb
@@ -398,7 +398,6 @@ By default, this RubyGems will install gem as:
env_shebang: options[:env_shebang],
format_executable: options[:format_executable],
force: options[:force],
- install_as_default: true,
bin_dir: bin_dir,
install_dir: default_dir,
wrappers: true
diff --git a/lib/rubygems/dependency_installer.rb b/lib/rubygems/dependency_installer.rb
index b4152e83e9..6fbfe53643 100644
--- a/lib/rubygems/dependency_installer.rb
+++ b/lib/rubygems/dependency_installer.rb
@@ -28,7 +28,6 @@ class Gem::DependencyInstaller
wrappers: true,
build_args: nil,
build_docs_in_background: false,
- install_as_default: false,
}.freeze
##
@@ -87,7 +86,6 @@ class Gem::DependencyInstaller
@wrappers = options[:wrappers]
@build_args = options[:build_args]
@build_docs_in_background = options[:build_docs_in_background]
- @install_as_default = options[:install_as_default]
@dir_mode = options[:dir_mode]
@data_mode = options[:data_mode]
@prog_mode = options[:prog_mode]
@@ -240,7 +238,6 @@ class Gem::DependencyInstaller
user_install: @user_install,
wrappers: @wrappers,
build_root: @build_root,
- install_as_default: @install_as_default,
dir_mode: @dir_mode,
data_mode: @data_mode,
prog_mode: @prog_mode,
diff --git a/lib/rubygems/install_default_message.rb b/lib/rubygems/install_default_message.rb
deleted file mode 100644
index 0640eaaf08..0000000000
--- a/lib/rubygems/install_default_message.rb
+++ /dev/null
@@ -1,13 +0,0 @@
-# frozen_string_literal: true
-
-require_relative "../rubygems"
-require_relative "user_interaction"
-
-##
-# A post-install hook that displays "Successfully installed
-# some_gem-1.0 as a default gem"
-
-Gem.post_install do |installer|
- ui = Gem::DefaultUserInteraction.ui
- ui.say "Successfully installed #{installer.spec.full_name} as a default gem"
-end
diff --git a/lib/rubygems/install_update_options.rb b/lib/rubygems/install_update_options.rb
index 57c41b7586..2d80e99787 100644
--- a/lib/rubygems/install_update_options.rb
+++ b/lib/rubygems/install_update_options.rb
@@ -161,7 +161,6 @@ module Gem::InstallUpdateOptions
add_option(:Deprecated, "--default",
"Add the gem's full specification to",
"specifications/default and extract only its bin") do |v,_o|
- options[:install_as_default] = v
end
add_option(:"Install/Update", "--explain",
diff --git a/lib/rubygems/installer.rb b/lib/rubygems/installer.rb
index 0cfe59b5bb..46c4844ab9 100644
--- a/lib/rubygems/installer.rb
+++ b/lib/rubygems/installer.rb
@@ -274,11 +274,7 @@ class Gem::Installer
run_pre_install_hooks
# Set loaded_from to ensure extension_dir is correct
- if @options[:install_as_default]
- spec.loaded_from = default_spec_file
- else
- spec.loaded_from = spec_file
- end
+ spec.loaded_from = spec_file
# Completely remove any previous gem files
FileUtils.rm_rf gem_dir
@@ -287,24 +283,17 @@ class Gem::Installer
dir_mode = options[:dir_mode]
FileUtils.mkdir_p gem_dir, mode: dir_mode && 0o755
- if @options[:install_as_default]
- extract_bin
- write_default_spec
- else
- extract_files
+ extract_files
- build_extensions
- write_build_info_file
- run_post_build_hooks
- end
+ build_extensions
+ write_build_info_file
+ run_post_build_hooks
generate_bin
generate_plugins
- unless @options[:install_as_default]
- write_spec
- write_cache_file
- end
+ write_spec
+ write_cache_file
File.chmod(dir_mode, gem_dir) if dir_mode
@@ -889,11 +878,7 @@ class Gem::Installer
ensure_loadable_spec
- if options[:install_as_default]
- Gem.ensure_default_gem_subdirectories gem_home
- else
- Gem.ensure_gem_subdirectories gem_home
- end
+ Gem.ensure_gem_subdirectories gem_home
return true if @force
diff --git a/test/rubygems/helper.rb b/test/rubygems/helper.rb
index b797960ac9..ecd92b0a57 100644
--- a/test/rubygems/helper.rb
+++ b/test/rubygems/helper.rb
@@ -811,7 +811,7 @@ class Gem::TestCase < Test::Unit::TestCase
def install_default_gems(*specs)
specs.each do |spec|
- installer = Gem::Installer.for_spec(spec, install_as_default: true)
+ installer = Gem::Installer.for_spec(spec)
installer.install
Gem.register_default_spec(spec)
end
diff --git a/test/rubygems/test_gem_installer.rb b/test/rubygems/test_gem_installer.rb
index 34415aa7dd..3fa617ef50 100644
--- a/test/rubygems/test_gem_installer.rb
+++ b/test/rubygems/test_gem_installer.rb
@@ -2425,119 +2425,6 @@ class TestGemInstaller < Gem::InstallerTestCase
assert_match %r{/gemhome/gems/a-2$}, installer.dir
end
- def test_default_gem_loaded_from
- spec = util_spec "a"
- installer = Gem::Installer.for_spec spec, install_as_default: true
- installer.install
- assert_predicate spec, :default_gem?
- end
-
- def test_default_gem_without_wrappers
- installer = setup_base_installer
-
- FileUtils.rm_rf File.join(Gem.default_dir, "specifications")
-
- installer.wrappers = false
- installer.options[:install_as_default] = true
- installer.gem_dir = @spec.gem_dir
-
- use_ui @ui do
- installer.install
- end
-
- assert_directory_exists File.join(@spec.gem_dir, "bin")
- installed_exec = File.join @spec.gem_dir, "bin", "executable"
- assert_path_exist installed_exec
-
- assert_directory_exists File.join(Gem.default_dir, "specifications")
- assert_directory_exists File.join(Gem.default_dir, "specifications", "default")
-
- default_spec = eval File.read File.join(Gem.default_dir, "specifications", "default", "a-2.gemspec")
- assert_equal Gem::Version.new("2"), default_spec.version
- assert_equal ["bin/executable"], default_spec.files
-
- assert_directory_exists util_inst_bindir
-
- installed_exec = File.join util_inst_bindir, "executable"
- assert_path_exist installed_exec
-
- wrapper = File.read installed_exec
-
- if symlink_supported?
- refute_match(/generated by RubyGems/, wrapper)
- else # when symlink not supported, it warns and fallbacks back to installing wrapper
- assert_match(/Unable to use symlinks, installing wrapper/, @ui.error)
- assert_match(/generated by RubyGems/, wrapper)
- end
- end
-
- def test_default_gem_with_wrappers
- installer = setup_base_installer
-
- installer.wrappers = true
- installer.options[:install_as_default] = true
- installer.gem_dir = @spec.gem_dir
-
- use_ui @ui do
- installer.install
- end
-
- assert_directory_exists util_inst_bindir
-
- installed_exec = File.join util_inst_bindir, "executable"
- assert_path_exist installed_exec
-
- wrapper = File.read installed_exec
- assert_match(/generated by RubyGems/, wrapper)
- end
-
- def test_default_gem_with_exe_as_bindir
- @spec = quick_gem "c" do |spec|
- util_make_exec spec, "#!/usr/bin/ruby", "exe"
- end
-
- util_build_gem @spec
-
- @spec.cache_file
-
- installer = util_installer @spec, @gemhome
-
- installer.options[:install_as_default] = true
- installer.gem_dir = @spec.gem_dir
-
- use_ui @ui do
- installer.install
- end
-
- assert_directory_exists File.join(@spec.gem_dir, "exe")
- installed_exec = File.join @spec.gem_dir, "exe", "executable"
- assert_path_exist installed_exec
-
- assert_directory_exists File.join(Gem.default_dir, "specifications")
- assert_directory_exists File.join(Gem.default_dir, "specifications", "default")
-
- default_spec = eval File.read File.join(Gem.default_dir, "specifications", "default", "c-2.gemspec")
- assert_equal Gem::Version.new("2"), default_spec.version
- assert_equal ["exe/executable"], default_spec.files
- end
-
- def test_default_gem_to_specific_install_dir
- @gem = setup_base_gem
- installer = util_installer @spec, "#{@gemhome}2"
- installer.options[:install_as_default] = true
-
- use_ui @ui do
- installer.install
- end
-
- assert_directory_exists File.join("#{@gemhome}2", "specifications")
- assert_directory_exists File.join("#{@gemhome}2", "specifications", "default")
-
- default_spec = eval File.read File.join("#{@gemhome}2", "specifications", "default", "a-2.gemspec")
- assert_equal Gem::Version.new("2"), default_spec.version
- assert_equal ["bin/executable"], default_spec.files
- end
-
def test_package_attribute
gem = quick_gem "c" do |spec|
util_make_exec spec, "#!/usr/bin/ruby", "exe"