Homebrew install via applescript app?


(Mike Lawrence) #1

Homebrew is already super easy to install, I know, but I’ve been asked to make a double-clickable installer for folks for whom even opening terminal and pasting the command is asking too much. I figured I’d make an applescript app and thought this would work:

do shell script "/usr/bin/ruby -e \"$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)\""

But when this runs, I the error

sudo: no tty present and no askpass program specified
Failed during: /usr/bin/sudo /bin/mkdir -p /usr/local/Frameworks

Any suggestions?


(Eric Knibbe) #2

This happens when the install script encounters a sudo command, which requires an interactive prompt. You could tack with administrator privileges on the end of the AppleScript command, but then the script itself will object to being run as root.

Personally, I’d save it as a shell script file, made executable and having the extension .command, which will run in Terminal when double-clicked.


(Mike Lawrence) #3

Hm, no luck; doing so yields the error message The file “install_homebrew.command” could not be executed because you do not have appropriate access privileges. Execution privileges need to be added to .command files, which requires going to the command line (what I’m trying to avoid in the first place).


(Mike Lawrence) #4

And homebrew now explicitly forbids running the installer as root, so the install fails.


(Mike Lawrence) #5

Figured it out: I just need to tell application "Terminal" ... rather than do shell script


(Jacob Ledbetter) #6

What if they use an application such as iTerm2?


(kyletcasey) #7

Hey Mike!

Can you elaborate on this for me? I’ve gotten as far as getting the terminal window to launch, but it doesn’t actually execute the script. Here’s what I’m using:

`on run {input, parameters}

tell application "Terminal"
	activate
	do script "/usr/bin/ruby -e \"$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" 
end tell

end run
`