make gem use sudo for macOS (#6610)

gem install requires sudo on official macOS build VMs.
- make bootstrap use sudo for macOS
This commit is contained in:
Travis Plunk 2018-04-10 12:18:11 -07:00 committed by GitHub
parent 18e6a5c654
commit aefc0d89b0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 10 deletions

View file

@ -1671,9 +1671,14 @@ function Start-PSBootstrap {
# Install [fpm](https://github.com/jordansissel/fpm) and [ronn](https://github.com/rtomayko/ronn)
if ($Package) {
try {
# We cannot guess if the user wants to run gem install as root
Start-NativeExecution { gem install fpm -v 1.9.3 }
Start-NativeExecution { gem install ronn -v 0.7.3 }
# We cannot guess if the user wants to run gem install as root on linux and windows,
# but macOs usually requires sudo
$gemsudo = ''
if($Environment.IsMacOS) {
$gemsudo = $sudo
}
Start-NativeExecution ([ScriptBlock]::Create("$gemsudo gem install fpm -v 1.9.3"))
Start-NativeExecution ([ScriptBlock]::Create("$gemsudo gem install ronn -v 0.7.3"))
} catch {
Write-Warning "Installation of fpm and ronn gems failed! Must resolve manually."
}

View file

@ -61,13 +61,6 @@ try {
if ($BootStrap.IsPresent) {
Start-PSBootstrap -Package
# The gem install is run by bootstrap without sudo and fails on macOS.
# Run the commands with sudo, to resolve the issue
Write-Verbose -Message "Installing fpm..." -Verbose
Start-NativeExecution { sudo gem install fpm -v 1.8.1 }
Write-Verbose -Message "Installing ronn..." -Verbose
Start-NativeExecution { sudo gem install ronn }
}
if ($Build.IsPresent) {