From 737d5432f9d7be097ab8ba11802165c9dc7a92df Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Sat, 21 Jun 2014 04:34:43 -0400 Subject: [PATCH] Add sudo when updating system ruby + abs path to gem --- rake/lib/rbenv.rb | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/rake/lib/rbenv.rb b/rake/lib/rbenv.rb index d643b1a6..682bcd04 100644 --- a/rake/lib/rbenv.rb +++ b/rake/lib/rbenv.rb @@ -5,6 +5,8 @@ module Rbenv BREWS = %w{rbenv ruby-build rbenv-bundler rbenv-vars rbenv-gem-rehash} + GEM_BIN = "/usr/local/opt/rbenv/shims/gem" + def self.bootstrap unless self.is_installed? BREWS.each { |pkg| Homebrew.install pkg } @@ -23,12 +25,13 @@ module Rbenv unless self.is_version_installed?(version) sh_safe "rbenv install #{version}" end - sh_safe "RBENV_VERSION=#{version} gem install #{gems.join(' ')}" + sh_safe "RBENV_VERSION=#{version} #{GEM_BIN} install #{gems.join(' ')}" end def self.update(version) - sh_safe "RBENV_VERSION=#{version} gem update" - sh_safe "RBENV_VERSION=#{version} gem clean" + cmd = self._sudo(version) + sh_safe "RBENV_VERSION=#{version} #{cmd} #{GEM_BIN} update" + sh_safe "RBENV_VERSION=#{version} #{cmd} #{GEM_BIN} clean" end def self.is_installed? @@ -43,4 +46,12 @@ module Rbenv `ls -1 #{Homebrew.prefix 'rbenv'}/versions`.split("\n") end + def self._sudo(version) + if version == 'system' + return "sudo" + else + return "" + end + end + end