Unable to install Homebrew + fish terminal (Mac) - macos

I am unable to install Homebrew(http://brew.sh/) using the fish command shell (http://fishshell.com/) on my Mac. Here is the error I get:
$(...) is not supported. In fish, please use '(curl)'.
fish: ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Please suggest!

Start bash and execute the unmodified command line.
Bash supports the syntax $(command) to return the text result of a command. Fish doesn't, but instead uses (command).

In Fish, command substitutions are just in parentheses, without the leading $. This should work:
ruby -e "(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Or you can just run that command from bash:
bash
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
exit

Related

Need sudo access on macOS - Installing Hashcat through Brew

I am trying to install Hashcat using the instructions on Brew: https://brewinstall.org/install-hashcat-on-mac-with-brew/
When I enter the first command:
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" < /dev/null 2> /dev/null
on terminal, it says:
Need sudo access on macOS (e.g. the user myname to be an Administrator)!
However, I am already an administrator when I check in Users&Groups in Systems Preferences. Typing sudo whoami also gives me back root
Can someone please help me out with this?
I'm pretty sure all you have to do is add sudo in front of the command like this:
sudo ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" < /dev/null 2> /dev/null

Installing HomeBrew doesn't work on Mojave

I type in Terminal:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
and I get back
illegal variable name
Any recommendations?
Maybe this is the same issue? https://discourse.brew.sh/t/illegal-variable-name-error-mac-high-sierra/3361/2.
could you run bash before pasting /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" there?
Simply open the terminal. Write the command as
bash
and press Enter button. Paste the same command as -
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Install homebrew using Makefile

I'm trying to install Homebrew using a Makefile, the contents of the Makefile is this:
.PHONY: install
install:
# Install homebrew
/usr/bin/ruby -e $(shell curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)
However this just prints the entire contents of the script, but it does not execute anything. I got as far as googling for this issue and seeing that the characters $, (, ) have a special meaning in a Makefile, however I could not find any solution.
try just piping output from curl to ruby like this:
.PHONY: install
install:
# Install homebrew
curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install | ruby
If you encounter the following warning:
Warning: The Ruby Homebrew install is now deprecated and has been rewritten in Bash.
Please migrate to the following command:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
You can modify #igagis answer as such
.PHONY:install
install:
curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh | bash
I was running into needing sudo, then sudo telling me not to run as root so the command i used was:
sudo true
curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh | sudo -u $$USER bash
Notes:
I use sudo true to run sudo and do nothing. that way the user can input their password. running sudo make from the terminal caused the $USER to be root. if you remove the sudo true line, then if sudo has not been run yet, the sudo access check will fail and not let you insert a password when running the curl line
the two $ makes the makefile write a literal $

Bypassing prompt (to press return) in homebrew install script

Very simple script that installs homebrew:
#!/bin/bash
ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"
The output gives:
==> 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
How do I press enter in a script like this? Would expect be the best route?
Reading the source of https://raw.github.com/Homebrew/homebrew/go/install -- it only prompts if stdin is a TTY. If you redirect stdin from /dev/null, it won't prompt at all. So:
ruby \
-e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" \
</dev/null
This is what yes is for:
yes '' | ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"
Per the lead maintainer of Homebrew:
echo | /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
this will work
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" < /dev/null
This works fine for me,
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" < /dev/null

Unattended (no-prompt) Homebrew installation using expect

According to the Homebrew installation instructions, the following command can be used to install:
ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"
This works, but it needs user input two times; to confirm the install and in a sudo prompt invoked by the script:
$ ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/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
==> /usr/bin/sudo /bin/mkdir /usr/local
Password:
Homebrew doesn't have arguments for unattended installations, so the only option I can think of is to programatically input the expected data. I tried using expect, but I can't quite get the syntax right:
$ expect -c 'spawn ruby -e \"\$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)\";expect "RETURN";send "\n"'
ruby: invalid option -f (-h will show valid options) (RuntimeError)
send: spawn id exp7 not open
while executing
"send "\n""
What am I doing wrong?
Unattended installation is now officially supported
https://docs.brew.sh/Installation#unattended-installation
If you want to create a setup script which installs homebrew silently then just pipe a blank echo to the homebrew's installer. Then redirect the results to /dev/null as #charles-duffy suggested.
#!/usr/bin/env bash
# install.sh
URL_BREW='https://raw.githubusercontent.com/Homebrew/install/master/install'
echo -n '- Installing brew ... '
echo | /usr/bin/ruby -e "$(curl -fsSL $URL_BREW)" > /dev/null
if [ $? -eq 0 ]; then echo 'OK'; else echo 'NG'; fi
$ ./install.sh

Resources