diff --git a/images/linux/scripts/SoftwareReport/SoftwareReport.Common.psm1 b/images/linux/scripts/SoftwareReport/SoftwareReport.Common.psm1 index eb634bb93..773442105 100644 --- a/images/linux/scripts/SoftwareReport/SoftwareReport.Common.psm1 +++ b/images/linux/scripts/SoftwareReport/SoftwareReport.Common.psm1 @@ -149,7 +149,7 @@ function Get-LernaVersion { } function Get-HomebrewVersion { - $result = Get-CommandResult "brew -v" + $result = Get-CommandResult "/home/linuxbrew/.linuxbrew/bin/brew -v" $result.Output -match "Homebrew (?\d+\.\d+\.\d+)" | Out-Null $version = $Matches.version return "Homebrew $version" diff --git a/images/linux/scripts/SoftwareReport/SoftwareReport.Generator.ps1 b/images/linux/scripts/SoftwareReport/SoftwareReport.Generator.ps1 index 7a7fad07b..872868170 100644 --- a/images/linux/scripts/SoftwareReport/SoftwareReport.Generator.ps1 +++ b/images/linux/scripts/SoftwareReport/SoftwareReport.Generator.ps1 @@ -84,6 +84,18 @@ $packageManagementList = @( ) $markdown += New-MDList -Style Unordered -Lines ($packageManagementList | Sort-Object) + +$markdown += New-MDHeader "Notes:" -Level 5 +$reportHomebrew = @' +``` +Location: /home/linuxbrew +Note: Homebrew is pre-installed on image but not added to PATH. +run the eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv) command +to accomplish this. +``` +'@ +$markdown += New-MDParagraph -Lines $reportHomebrew + $markdown += New-MDHeader "Environment variables" -Level 4 $markdown += Build-PackageManagementEnvironmentTable | New-MDTable $markdown += New-MDNewLine diff --git a/images/linux/scripts/installers/homebrew.sh b/images/linux/scripts/installers/homebrew.sh index c37d3876b..1b4cbd21c 100644 --- a/images/linux/scripts/installers/homebrew.sh +++ b/images/linux/scripts/installers/homebrew.sh @@ -11,14 +11,10 @@ source $HELPER_SCRIPTS/install.sh # Install the Homebrew on Linux /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)" -brew_shellenv="/home/linuxbrew/.linuxbrew/bin/brew shellenv" -# Update /etc/environment -## Put HOMEBREW_* variables. -$brew_shellenv | grep 'export HOMEBREW' | sed -E 's/^export (.*);$/\1/' | tr -d '"' | sudo tee -a /etc/environment -# add brew executables locations to PATH -brew_path=$($brew_shellenv | grep '^export PATH' | sed -E 's/^export PATH="([^$]+)\$.*/\1/') -prependEtcEnvironmentPath "$brew_path" +# Invoke shellenv to make brew available during runnig session +eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)" + setEtcEnvironmentVariable HOMEBREW_NO_AUTO_UPDATE 1 setEtcEnvironmentVariable HOMEBREW_CLEANUP_PERIODIC_FULL_DAYS 3650 diff --git a/images/linux/scripts/tests/Tools.Tests.ps1 b/images/linux/scripts/tests/Tools.Tests.ps1 index 5d7c5a854..5e39bc871 100644 --- a/images/linux/scripts/tests/Tools.Tests.ps1 +++ b/images/linux/scripts/tests/Tools.Tests.ps1 @@ -261,7 +261,7 @@ Describe "Homebrew" { $testCases = $brewToolset | ForEach-Object { @{brewName = $_.name; brewCommand = $_.command} } It "homebrew" { - "brew --version" | Should -ReturnZeroExitCode + "/home/linuxbrew/.linuxbrew/bin/brew --version" | Should -ReturnZeroExitCode } It "zstd has /usr/local/bin symlink" { @@ -269,7 +269,7 @@ Describe "Homebrew" { } It "homebrew package " -TestCases $testCases { - $brewPrefix = brew --prefix $brewName + $brewPrefix = /home/linuxbrew/.linuxbrew/bin/brew --prefix $brewName $brewPackage = Join-Path $brewPrefix "bin" $brewCommand "$brewPackage --version" | Should -ReturnZeroExitCode