Skip to content

Commit

Permalink
Merge pull request #3975 from rubygems/buildroot_windows
Browse files Browse the repository at this point in the history
Fix `--build-root` flag under Windows
  • Loading branch information
deivid-rodriguez committed Sep 30, 2020
2 parents 4b3e48c + 40180af commit 9b25442
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
6 changes: 2 additions & 4 deletions lib/rubygems/installer.rb
Expand Up @@ -693,10 +693,8 @@ def process_options # :nodoc:
@build_args = options[:build_args] || Gem::Command.build_args

unless @build_root.nil?
require 'pathname'
@build_root = Pathname.new(@build_root).expand_path
@bin_dir = File.join(@build_root, options[:bin_dir] || Gem.bindir(@gem_home))
@gem_home = File.join(@build_root, @gem_home)
@bin_dir = File.join(@build_root, @bin_dir.gsub(/^[a-zA-Z]:/, ''))
@gem_home = File.join(@build_root, @gem_home.gsub(/^[a-zA-Z]:/, ''))
alert_warning "You build with buildroot.\n Build root: #{@build_root}\n Bin dir: #{@bin_dir}\n Gem home: #{@gem_home}"
end
end
Expand Down
17 changes: 13 additions & 4 deletions test/rubygems/test_gem_installer.rb
Expand Up @@ -794,7 +794,7 @@ def test_generate_plugins_with_user_install

assert_equal spec, installer.install

assert !File.exist?(system_path), 'plugin not written to user plugins_dir'
assert !File.exist?(system_path), 'plugin incorrectly written to system plugins_dir'
assert File.exist?(user_path), 'plugin not written to user plugins_dir'
end

Expand Down Expand Up @@ -1156,6 +1156,15 @@ def test_install_force
assert_path_exists gem_dir
end

def test_install_build_root
build_root = File.join(@tempdir, 'build_root')

@gem = setup_base_gem
installer = Gem::Installer.at @gem, :build_root => build_root

assert_equal @spec, installer.install
end

def test_install_missing_dirs
installer = setup_base_installer

Expand Down Expand Up @@ -1786,9 +1795,9 @@ def test_process_options_build_root
@gem = setup_base_gem
installer = Gem::Installer.at @gem, :build_root => build_root

assert_equal Pathname(build_root), installer.build_root
assert_equal File.join(build_root, @gemhome, 'bin'), installer.bin_dir
assert_equal File.join(build_root, @gemhome), installer.gem_home
assert_equal build_root, installer.build_root
assert_equal File.join(build_root, @gemhome.gsub(/^[a-zA-Z]:/, ''), 'bin'), installer.bin_dir
assert_equal File.join(build_root, @gemhome.gsub(/^[a-zA-Z]:/, '')), installer.gem_home
end

def test_shebang_arguments
Expand Down

0 comments on commit 9b25442

Please sign in to comment.