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