Skip to content

Commit 9e8100a

Browse files
committed
Simulate default gems manually
1 parent ba6e63f commit 9e8100a

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

bundler/spec/support/helpers.rb

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,9 +335,20 @@ def install_gem(path, install_dir, default = false)
335335
raise "OMG `#{path}` does not exist!" unless File.exist?(path)
336336

337337
args = "--no-document --ignore-dependencies --verbose --local --install-dir #{install_dir}"
338-
args += " --default" if default
339338

340339
gem_command "install #{args} '#{path}'"
340+
341+
if default
342+
gem = Pathname.new(path).basename.to_s.match(/(.*)\.gem/)[1]
343+
344+
# Revert Gem::Installer#write_spec and apply Gem::Installer#write_default_spec
345+
FileUtils.mkdir_p File.join(install_dir, "specifications", "default")
346+
File.rename File.join(install_dir, "specifications", gem + ".gemspec"),
347+
File.join(install_dir, "specifications", "default", gem + ".gemspec")
348+
349+
# Revert Gem::Installer#write_cache_file
350+
File.delete File.join(install_dir, "cache", gem + ".gem")
351+
end
341352
end
342353

343354
def with_built_bundler(version = nil, &block)

0 commit comments

Comments
 (0)