Add sudo when updating system ruby + abs path to gem

This commit is contained in:
Henrik Lissner 2014-06-21 04:34:43 -04:00
parent 3e44526021
commit 737d5432f9

View file

@ -5,6 +5,8 @@ module Rbenv
BREWS = %w{rbenv ruby-build rbenv-bundler rbenv-vars rbenv-gem-rehash} BREWS = %w{rbenv ruby-build rbenv-bundler rbenv-vars rbenv-gem-rehash}
GEM_BIN = "/usr/local/opt/rbenv/shims/gem"
def self.bootstrap def self.bootstrap
unless self.is_installed? unless self.is_installed?
BREWS.each { |pkg| Homebrew.install pkg } BREWS.each { |pkg| Homebrew.install pkg }
@ -23,12 +25,13 @@ module Rbenv
unless self.is_version_installed?(version) unless self.is_version_installed?(version)
sh_safe "rbenv install #{version}" sh_safe "rbenv install #{version}"
end end
sh_safe "RBENV_VERSION=#{version} gem install #{gems.join(' ')}" sh_safe "RBENV_VERSION=#{version} #{GEM_BIN} install #{gems.join(' ')}"
end end
def self.update(version) def self.update(version)
sh_safe "RBENV_VERSION=#{version} gem update" cmd = self._sudo(version)
sh_safe "RBENV_VERSION=#{version} gem clean" sh_safe "RBENV_VERSION=#{version} #{cmd} #{GEM_BIN} update"
sh_safe "RBENV_VERSION=#{version} #{cmd} #{GEM_BIN} clean"
end end
def self.is_installed? def self.is_installed?
@ -43,4 +46,12 @@ module Rbenv
`ls -1 #{Homebrew.prefix 'rbenv'}/versions`.split("\n") `ls -1 #{Homebrew.prefix 'rbenv'}/versions`.split("\n")
end end
def self._sudo(version)
if version == 'system'
return "sudo"
else
return ""
end
end
end end