Skip to content

Commit

Permalink
Fix download strategy to use the correct gem exe
Browse files Browse the repository at this point in the history
  • Loading branch information
nicksieger committed Nov 6, 2017
1 parent 0dc0f04 commit 2a061c7
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions lib/brew/gem/formula.rb.erb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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'
Expand Down

0 comments on commit 2a061c7

Please sign in to comment.