Homebrew installation in mac is giving error - macos

I want to install homebrew on my mac system but i am not able to install. Installation process is giving me error.
error: could not lock config file /usr/local/Homebrew/.git/config: Permission denied
fatal: could not set 'core.repositoryformatversion' to '0'
Failed during: git init -q
I have tried below command to install homebrew
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Remove the current installation with:
sudo rm -rf /usr/local/Homebrew
and install it again without using sudo:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

the location have change so now use this :
sudo rm -rf /opt/homebrew
and install again with :
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Related

Homebrew incompatible architecture error on M1 MacBook

I am getting below error while running /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" on my new M1 MacBook pro 16.
kevin#MacBook-Pro ~ % /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
==> Checking for `sudo` access (which may request your password)...
Password:
==> This script will install:
/opt/homebrew/bin/brew
/opt/homebrew/share/doc/homebrew
/opt/homebrew/share/man/man1/brew.1
/opt/homebrew/share/zsh/site-functions/_brew
/opt/homebrew/etc/bash_completion.d/brew
/opt/homebrew
Press RETURN/ENTER to continue or any other key to abort:
==> /usr/bin/sudo /usr/sbin/chown -R kevin:admin /opt/homebrew
==> Downloading and installing Homebrew...
xcrun: error: unable to load libxcrun (dlopen(/Library/Developer/CommandLineTools/usr/lib/libxcrun.dylib, 0x0005): tried: '/Library/Developer/CommandLineTools/usr/lib/libxcrun.dylib' (mach-o file, but is an incompatible architecture (have (x86_64), need (arm64e)))).
Failed during: git init -q
kevin#MacBook-Pro ~ %
This is my first time setting up development on macOS so please do let me know if I am missing something here.
Deleting /Library/Developer/CommandLineTools with sudo rm -rf /Library/Developer/CommandLineToolsand running /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Homebrew installation error: "not a valid ref: refs/remotes/origin/master"?

I have tried to install Homebrew on macOS Monterey by following the instructions at https://brew.sh/.
But it resulted in:
error: Not a valid ref: refs/remotes/origin/master
Error: Fetching /opt/homebrew/Library/Taps/homebrew/homebrew-core failed!
fatal: invalid upstream 'origin/master'
Failed during: /opt/homebrew/bin/brew update --force --quiet
I encountered this error on my brand new Macbook Pro with the M2 processor. What worked for me was removing the contents of the homebrew directory
rm -rf /opt/homebrew
Then running the uninstall script (its the same as the intall script on the homebrew except change the last part from install to uninstall. Assuming the link has not changed on the homebrew website I ran these two commands and it installed successfully.
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/uninstall.sh)"
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
You can run brew -v or brew doctor to check if your install is good.
My error was after a failed previous install with WSL... so same on windows, only:
cd /home
sudo rm -rf homebrew/
This worked on M1.
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/uninstall.sh)"
git config --global core.compression 0
git config --global http.postBuffer 1048576000
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"

Brew installation - not a valid reference error

I am trying to install homebrew on macos m1 chip, with the one-line command but keep running into the following error. Could someone please help me to fix this? Thank you.
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
==> Checking for `sudo` access (which may request your password)...
Password:
==> This script will install:
/opt/homebrew/bin/brew
/opt/homebrew/share/doc/homebrew
/opt/homebrew/share/man/man1/brew.1
/opt/homebrew/share/zsh/site-functions/_brew
/opt/homebrew/etc/bash_completion.d/brew
/opt/homebrew
Press RETURN to continue or any other key to abort:
==> /usr/bin/sudo /usr/sbin/chown -R miththinda:admin /opt/homebrew
==> Downloading and installing Homebrew...
HEAD is now at a0ae4a7a0 Merge pull request #12658 from sjackman/sj/linkage-checker
error: Not a valid ref: refs/remotes/origin/master
fatal: ambiguous argument 'refs/remotes/origin/master': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
Removing the directory and trying to reinstall worked for me.
sudo rm -rf /opt/homebrew
Please run the following commands in your terminal:
rm -fr $(brew --repo homebrew/core) # because you can't `brew untap homebrew/core`
brew tap homebrew/core
You can check the details of the issue here.
Had a similar issue on Mac, I uninstalled it first by typing the command below and I installed Xcode, it worked for me after running the install command again.
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall)"
I first installed it onto my Linux system using the command recommended on the homebrew install page:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
but it seem to take a long time, and "hung" showing the output:
Resolving deltas: 100% (793706/793706), done.
for quite a while. I was impatient and killed the process then, and tried the install again. That is when I got the error reported by the OP. The fix was to uninstall the partially installed homebrew, and install again:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall.sh)"
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Homebrew Installed But Also Not Installed

When I tried to install homebrew I got this error. It started simple but then I was perplexed.
cjbrigna$ 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
==> /usr/bin/sudo /usr/bin/chgrp admin /Library/Caches/Homebrew
Password:
==> Downloading and installing Homebrew...
fatal: unable to access 'https://github.com/Homebrew/homebrew/': Could not resolve host: github.com
Failed during: git fetch origin master:refs/remotes/origin/master -n --depth=1
No problem, github was down for a little while. So I tried again later.
cjbrigna$ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
It appears Homebrew is already installed. If your intent is to reinstall you
should do the following before running this installer again:
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall)"
Which makes me think I have homebrew.
cjbrigna$ brew help
-sh: brew: command not found
Well clearly I didn't have homebrew.
cjbrigna$ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall)"
Failed to locate Homebrew!
Well now I can't install or uninstall homebrew. This makes no sense. What did I do wrong? I appreciate any help.
You can finish the install process manually:
cd /usr/local
git fetch origin master:refs/remotes/origin/master -n --depth=1
git reset --hard origin/master
Then ensure /usr/local/bin is in your PATH. If it is you should then be able to run e.g. brew help to check that Homebrew is installed.

What is the best/safest way to reinstall Homebrew?

I am getting issues with permissions in Homebrew: After I installed Node and tried to install npm using the curl command Homebrew tells you to use, it would fail due to EACCESS errors. I checked the node folder and the permissions were a) unowned by a user (I had to chown it) and b) Had no write permissions (I had to chmod 755 it).
I've fixed the issue with NPM, but I had to run its install script as sudo (which is bad!).
I assume I must have installed Homebrew as root or something similar. I am hoping that reinstallation will fix it, but I can't find a source on how to reinstall Homebrew.
When I rerun the installer in Terminal I get:
/usr/local/.git already exists!
Update 10/11/2020 to reflect the latest brew changes.
Brew already provide a command to uninstall itself (this will remove everything you installed with Homebrew):
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall.sh)"
If you failed to run this command due to permission (like run as second user), run again with sudo
Then you can install again:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
Process is to clean up and then reinstall with the following commands:
rm -rf /usr/local/Cellar /usr/local/.git && brew cleanup
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install )"
Notes:
Always check curl | bash (or ruby) commands before running them
http://brew.sh/ (for installation notes)
https://raw.githubusercontent.com/Homebrew/install/master/install (for clean up notes, see "Homebrew is already installed")
Try running the command
brew doctor
and let us know what sort of output you get
edit: And to answer the title question, this is from their FAQ :
Homebrew doesn’t write files outside its prefix. So generally you can
just rm -rf the folder you installed it in.
So following that up with a clean re-install (following their latest recommended steps) should be your best bet.
For Mac OS X Mojave and above
To Uninstall Homebrew, run following command:
sudo ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall)"
To Install Homebrew, run following command:
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
And if you run into Permission denied issue, try running this command followed by install command again:
sudo chown -R $(whoami):admin /usr/local/* && sudo chmod -R g+rwx /usr/local/*
The way to reinstall Homebrew is completely remove it and start over. The Homebrew FAQ has a link to a shell script to uninstall homebrew.
If the only thing you've installed in /usr/local is homebrew itself, you can just rm -rf /usr/local/* /usr/local/.git to clear it out. But /usr/local/ is the standard Unix directory for all extra binaries, not just Homebrew, so you may have other things installed there. In that case uninstall_homebrew.sh is a better bet. It is careful to only remove homebrew's files and leave the rest alone.
For me, I need to do the below steps to re-install the brew from scratch.
sudo rm -rf /usr/local/Cellar/
brew cleanup
sudo rm -rf $(brew --repo)
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
You can try this method for M1 macbook
After you
1.Uninstall brew
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall.sh)"
2.Install brew again
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
3.You brew install something in image I "brew install sonar-scanner"
then error log show same this
Error: No similarly named formulae found.
4.You should try follow run this.
rm -rf "/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core"
5.When no.4 is done run this
brew tap homebrew/core
try brew install again.
For me, this one worked without the sudo access.
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
For more reference, please follow
https://gist.github.com/mxcl/323731

Resources