Skip to content

Commit be47f6d

Browse files
committed
Simulate default gems manually
1 parent 9a4fd40 commit be47f6d

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
@@ -333,9 +333,20 @@ def install_gem(path, install_dir, default = false)
333333
raise "OMG `#{path}` does not exist!" unless File.exist?(path)
334334

335335
args = "--no-document --ignore-dependencies --verbose --local --install-dir #{install_dir}"
336-
args += " --default" if default
337336

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

341352
def with_built_bundler(version = nil, opts = {}, &block)

0 commit comments

Comments
 (0)