Skip to content

Commit

Permalink
Make --default and --install-dir play nice together
Browse files Browse the repository at this point in the history
With this combination of flags, `rubygems` should install the default
specification to `--install-dir`, not to the default rubygems
installation.

I doubt this has any realworld use cases, but fixing it is handy for me
in order to be able to write a test for a bug fix in `bundler` related
to `bundle clean --force` removing executables of default gems.
  • Loading branch information
deivid-rodriguez committed Aug 27, 2020
1 parent 5b78364 commit b7fb3bd
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/rubygems/installer.rb
Expand Up @@ -433,7 +433,7 @@ def spec_file
#

def default_spec_file
File.join Gem.default_specifications_dir, "#{spec.full_name}.gemspec"
File.join gem_home, "specifications", "default", "#{spec.full_name}.gemspec"
end

##
Expand Down
17 changes: 17 additions & 0 deletions test/rubygems/test_gem_installer.rb
Expand Up @@ -2170,6 +2170,23 @@ def test_default_gem_with_exe_as_bindir
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'
Expand Down

0 comments on commit b7fb3bd

Please sign in to comment.