From dc83e450b7bc6a0311b888dd5c3a29405c12d9cd Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Thu, 18 Apr 2024 17:40:49 +0900 Subject: [PATCH] Simulate default gems manually --- bundler/spec/support/helpers.rb | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/bundler/spec/support/helpers.rb b/bundler/spec/support/helpers.rb index 1ad9cc78ca19..4d42e8128f36 100644 --- a/bundler/spec/support/helpers.rb +++ b/bundler/spec/support/helpers.rb @@ -321,9 +321,20 @@ def install_gem(path, install_dir, default = false) raise "OMG `#{path}` does not exist!" unless File.exist?(path) args = "--no-document --ignore-dependencies --verbose --local --install-dir #{install_dir}" - args += " --default" if default gem_command "install #{args} '#{path}'" + + if default + gem = Pathname.new(path).basename.to_s.match(/(.*)\.gem/)[1] + + # Revert Gem::Installer#write_spec and apply Gem::Installer#write_default_spec + FileUtils.mkdir_p File.join(install_dir, "specifications", "default") + File.rename File.join(install_dir, "specifications", gem + ".gemspec"), + File.join(install_dir, "specifications", "default", gem + ".gemspec") + + # Revert Gem::Installer#write_cache_file + File.delete File.join(install_dir, "cache", gem + ".gem") + end end def with_built_bundler(version = nil, &block)