From 2a061c7be680a810e05206fd9116138d8f3b2a59 Mon Sep 17 00:00:00 2001 From: Nick Sieger Date: Mon, 6 Nov 2017 12:41:23 -0600 Subject: [PATCH 1/2] Fix download strategy to use the correct gem exe --- lib/brew/gem/formula.rb.erb | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/lib/brew/gem/formula.rb.erb b/lib/brew/gem/formula.rb.erb index 54a0806..fcd998c 100644 --- a/lib/brew/gem/formula.rb.erb +++ b/lib/brew/gem/formula.rb.erb @@ -3,12 +3,16 @@ require 'formula' require 'fileutils' +BREWGEM_RUBYBINDIR = '<%= use_homebrew_ruby ? "#{homebrew_prefix}/bin" : "/usr/bin" %>' +BREWGEM_GEM_PATH = "#{BREWGEM_RUBYBINDIR}/gem" +BREWGEM_RUBY_PATH = "#{BREWGEM_RUBYBINDIR}/ruby" + class RubyGemsDownloadStrategy < AbstractDownloadStrategy def fetch ohai "Fetching <%= name %> from gem source" HOMEBREW_CACHE.cd do ENV['GEM_SPEC_CACHE'] = "#{HOMEBREW_CACHE}/gem_spec_cache" - system "gem", "fetch", "<%= name %>", "--version", resource.version + system BREWGEM_GEM_PATH, "fetch", "<%= name %>", "--version", resource.version end end @@ -38,10 +42,7 @@ class <%= klass %> < Formula ENV['GEM_HOME']="#{prefix}" ENV['GEM_PATH']="#{prefix}" - rubybindir = '<%= use_homebrew_ruby ? "#{homebrew_prefix}/bin" : "/usr/bin" %>' - gem_path = "#{rubybindir}/gem" - ruby_path = "#{rubybindir}/ruby" - system gem_path, "install", cached_download, + system BREWGEM_GEM_PATH, "install", cached_download, "--no-ri", "--no-rdoc", "--no-wrapper", @@ -74,7 +75,7 @@ class <%= klass %> < Formula file = Pathname.new("#{brew_gem_prefix}/#{gemspec.bindir}/#{exe}") (bin+file.basename).open('w') do |f| f << <<-RUBY -#!#{ruby_path} --disable-gems +#!#{BREWGEM_RUBY_PATH} --disable-gems ENV['GEM_HOME']="#{prefix}" ENV['GEM_PATH']="#{prefix}" require 'rubygems' From ca06de226d08ef576c672112a26aac9730fa06b2 Mon Sep 17 00:00:00 2001 From: Nick Sieger Date: Tue, 7 Nov 2017 10:02:28 -0600 Subject: [PATCH 2/2] Fix expand formula specs --- spec/brew/gem/cli_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/brew/gem/cli_spec.rb b/spec/brew/gem/cli_spec.rb index df4a926..3aa7e8d 100644 --- a/spec/brew/gem/cli_spec.rb +++ b/spec/brew/gem/cli_spec.rb @@ -15,11 +15,11 @@ it { is_expected.to match(/class GemFooBar < Formula/) } it { is_expected.to match(/version "1\.2\.3"/) } - it { is_expected.to match("rubybindir = '/usr/bin'") } + it { is_expected.to match("BREWGEM_RUBYBINDIR = '/usr/bin'") } context "homebrew-ruby" do subject(:formula) { described_class.expand_formula("foo-bar", "1.2.3", true) } - it { is_expected.to match("rubybindir = '/usr/local/bin'") } + it { is_expected.to match("BREWGEM_RUBYBINDIR = '/usr/local/bin'") } end end