Trying to install Homebrew on Big Sur 11.2.3
Using:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
in my Terminal
Getting:
"Illegal variable name"
The above code installed fine on a VM of High Sierra an hour ago. so I know it works
Anyone have any ideas why it is not working on Big Sur?
Best Answer
You need to install homebrew with this command:
Note: Use
/bin/bash
rather than/usr/bin/ruby
.The
curl
command inside the$()
expression is executed and returns the content of theinstall.sh
file. Then, the shell replaces the$()
expression with these install instructions. As the install instructions are written forbash
rather thanruby
,bash
is needed to execute them.I could not reproduce the "illegal variable name" issue, however. Therefore, here are a couple of other workarounds that might help:
Option 1: Switch to bash or zsh
The "illegal variable name" could occur if you are not using
bash
orzsh
as your terminal shell, butcsh
ortcsh
instead. (You could find out usingecho $0
.)Try switching to
bash
orzsh
before executing the install command:The first line starts a
zsh
shell. (You can also try/bin/bash
instead, but I think, Big Sur useszsh
by default, now.) Then the second line is executed in this shell, which should circumvent the "illegal variable name" error.The reason is that the
bash
andzsh
shells might handle the$()
expansion differently thancsh
andtcsh
. Ifcsh
interprets everything after the$
as variable, it might consider$(...
is an illegal variable name.Option 2: Install from downloaded file
If, as mentioned in the comments, you have already downloaded the
install.sh
file, try executing the following in your terminal:Here,
/path/to/install.sh
needs to be replaced by the actual path of the downloaded file. You could just type/bin/bash
and then drag-and-drop the file to your terminal, which should insert the path.