palantir/jamf-pro-scripts

Homebrew Casks - Outdated.sh: Error: $PWD must be set to run brew.

Closed this issue · 2 comments

Thanks for contributing Homebrew Casks - Outdated.sh.

When running as-is in an elevated Terminal session on macOS 14.2.1 (23C71), I observed the following error:

# sh /Users/dan/Downloads/Homebrew\ Casks\ -\ Outdated.sh 
<result>shell-init: error retrieving current directory: getcwd: cannot access parent directories: Permission denied
Error: $PWD must be set to run brew.</result>

Changing Line 57 to the following seems to be working as expected:

brewOutdatedCask=$(/usr/bin/su \- "$loggedInUser" -c "'$brewPath' outdated --cask --quiet 2>&1")

# sh /Users/dan/Downloads/Homebrew\ Casks\ -\ Outdated.sh 
<result>Running `brew update --auto-update`...
==> Auto-updated Homebrew!
Updated 2 taps (homebrew/core and homebrew/cask).
==> New Formulae
scnlib
==> New Casks
insomnium

You have 3 outdated formulae installed.</result>

I'm seeing the same behavior when switching to root in Terminal, but it doesn't seem to impact the extension attribute's ability to function from Jamf Pro; I see plenty of devices reporting the expected output from that command in recent computer reports. If you're seeing issues with this script when Jamf Pro executes it as part of an inventory update, let me know what output you're seeing in the Jamf Pro console.

@mpanighetti:

If this working as-is for you, I’ll go ahead and close this issue.

Thanks.