Skip to content
This repository has been archived by the owner on Jul 4, 2023. It is now read-only.

Unattended install #46779

Closed
pixelrebel opened this issue Dec 7, 2015 · 5 comments
Closed

Unattended install #46779

pixelrebel opened this issue Dec 7, 2015 · 5 comments

Comments

@pixelrebel
Copy link

I can't figure out how to install homebrew without user interaction. No matter what I do I'm either prompted to hit RETURN key or enter sudo password. I've tried the following:

$ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" < /dev/null
==> This script will install:
/usr/local/bin/brew
/usr/local/Library/...
/usr/local/share/man/man1/brew.1
==> /usr/bin/sudo /bin/mkdir /Library/Caches/Homebrew
Password:

$ sudo ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" < /dev/null
Password:
Don't run this as root!

$ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
==> This script will install:
/usr/local/bin/brew
/usr/local/Library/...
/usr/local/share/man/man1/brew.1

Press RETURN to continue or any other key to abort
@DomT4
Copy link
Member

DomT4 commented Dec 7, 2015

Using that script, you can't practically. That script is very much intended to require user interaction and permission, given the changes it makes. What's your use case that requires silent installation?

@pixelrebel
Copy link
Author

Thanks for the quick reply @DomT4.

I'm building an installer pkg using theluggage for a custom tool I'm building. The tool has a lot of dependancies, so it would be really great to leverage homebrew within my installer.

EDIT: I should also mention that my installer pkg installs command line tools for 10.8 and up. So the homebrew dependancies are covered.

@DomT4
Copy link
Member

DomT4 commented Dec 7, 2015

No worries!

You could probably do something like:

#!/bin/bash
git clone https://github.com/Homebrew/homebrew.git /desired/path
export PATH="/path/to/brew/bin":$PATH
export HOMEBREW_CACHE="/path/you/know/you/can/write/into"
export HOMEBREW_LOGS="/path/you/know/you/can/write/into"
brew update
brew install xyz

If you stuck with /usr/local you'd need to add steps in that script to ensure the directory was user-writable.

If you're planning to run this or tell users to run this on machines you don't own it's probably a good idea to give users a heads-up on that first, and if they need to retain brew after installation to tell them to add it permanently to the $PATH.

@pixelrebel
Copy link
Author

Oh great, I didn't even consider this for a one-time use!

But, say I want to permanently install homebrew (as a bonus).
I would just add the following?

sudo chmod 775 /usr/local
sudo chown root:admin /usr/local
mkdir /usr/local/bin
cp /tmp/homebrew/bin/brew /usr/local/bin
cp -r /tmp/homebrew/Library /usr/local
cp -r /tmp/homebrew/share /usr/local
sudo mkdir /Library/Caches/Homebrew

This doesn't include the checks for preexisting files/dirs, but you get the gist.

Where does homebrew put the logs? Am I missing anything else?

@MikeMcQuaid
Copy link
Member

You can use it non-interactively, it just checks if it's being run in a terminal with interactivity. https://github.com/Homebrew/install/blob/fabfe35de50e23464a52deedcc1954e95e302ee7/install#L183

echo | ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" will make it run without prompting in a Terminal (although that isn't needed in a script running in e.g. Jenkins or something that's not a TTY).

https://github.com/mikemcquaid/strap is an option for a full system install.

I'm building an installer pkg using theluggage for a custom tool I'm building. The tool has a lot of dependancies, so it would be really great to leverage homebrew within my installer.

EDIT: I should also mention that my installer pkg installs command line tools for 10.8 and up. So the homebrew dependancies are covered.

Please don't autoinstall Homebrew in your installer; if people have Homebrew already installed (particularly in a different location it'll be extremely confusing) when you install a bunch of new packages for them. The right thing to do is to build everything you need yourself and bundle the output binaries into your .pkg or, ideally, .app bundle.

@Homebrew Homebrew locked and limited conversation to collaborators Jul 10, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants