Can't install homebrew

11,119

I was able to install Homebrew using the following steps. Note I did this on a non-root admin user account. I had to create this user account separately and give it admin access just to do this. Once I logged out of my root account and logged into the admin non-root account, I typed the following commands into terminal:

xcode-select --install cd /usr/local/Homebrew git init git remote add origin https://github.com/Homebrew/brew git fetch --all git checkout -B master origin/master cd /usr/local ln -s /usr/local/Homebrew/bin/brew /usr/local/bin

I found most of these steps here:

https://github.com/Homebrew/homebrew-core/issues/5084#issuecomment-248834806

Hope this helps someone else.

Share:
11,119
Bryan Miller
Author by

Bryan Miller

I love Laravel, PHP, Javascript, CSS, and HTML. I have an undergrad in Electrical Engineering, but enjoy programming much more! I built the website Save My Research - check it out!

Updated on August 22, 2022

Comments

  • Bryan Miller
    Bryan Miller over 1 year

    I have a fairly new macbook pro and I'm simply trying to install homebrew according to the directions on their site:

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

    However, when I run this I get the following output:

    The user \u cannot be found There was an unknown error. This script requires the user \u to be an Administrator.

    My macbook only has 1 user, which is me, the Administrator. That's who I'm logged in as on the computer.

    Another thing I've tried is running the command with sudo, in which case I get the following message:

    Don't run this as root!

    Another thing I've tried is downloading Command Line Tools (CLT) for Xcode: xcode-select --install as I saw this suggested on Homebrew's site and elsewhere online.

    After creating a new user with "Admin" privileges apart from my root account, the homebrew install command above started to run but then quit with the following error:

    /usr/local/homebrew/.git: Permission denied Failed during: git init -q

    At this point I'm stuck and not sure what to do.

  • Bryan Miller
    Bryan Miller about 6 years
    Thanks for your suggestion, but yes, I tried that, and I get the same error message. When I run the xcode command again it says "command line tools are already installed".
  • Daniel Lara
    Daniel Lara about 6 years
    It seems that somehow you are not the admin of the system. You can try sudo su and then the ruby command to switch to root user before issuing the command or simply check that you are the admin in the system settings. It seems that Homebrew issued a warning in other versions: "set your user to be an Administrator in System Preferences or `su' to a non-root user with Administrator privileges". See: teamtreehouse.com/community/…
  • Bryan Miller
    Bryan Miller about 6 years
    When I open System Preferences and look under the "Users & Groups" menu item, it says the "Current User" is myself and it says "Admin" under that. It's probable that I'm the "root" user, but I'm not sure how to switch to a non-root user or how to use "su".
  • Bryan Miller
    Bryan Miller about 6 years
    I created another user with Admin privileges and logged out of my root account, then logged back in as this other user. I was able to run the homebrew installation command, but it quit midway through with the below error: /usr/local/homebrew/.git: Permission denied Failed during: git init -q
  • Steven Aguilar
    Steven Aguilar about 6 years
    Do you have git installed? run git --version whats the output?
  • Janet
    Janet about 5 years
    I was created as a standard user and could not run this command: /usr/bin/ruby -e "$(curl -fsSL raw.githubusercontent.com/Homebrew/install/master/install)" so I logged out, logged in using admin username and password and made my account admin, logged back in and reran the command, it worked.
  • Bryan Miller
    Bryan Miller about 5 years
    Yeah, as long as you're not the root user admin and just a non-root user admin, that is what worked for me, though I wonder if things have changed since this was a while ago.
  • Diana
    Diana about 4 years
    just for those who are a bit slow like me: make the directory mkdir /usr/loca/Homebrew, probably you will need to put sudo before it
  • user2568374
    user2568374 almost 2 years
    first line says already installed, 2nd line says no such file or directory ?????