How to get back Homebrew to previous state? - macos

I deleted some of .rb files(cassandra.rb,cassandra#2.1.rb and cassandra#2.2.rb) from folder /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/ from mac system.I want back those .rb files.I thought brew upgrade will give me back those deleted .rb files back.But they are still missing. Those .rb files are important for me to install packages.
brew install cassandra gives
Updating Homebrew...
Error: No available formula with the name "cassandra"
==> Searching for a previously deleted formula...
cassandra was deleted from homebrew/core in commit d20fe73:
cassandra: update 3.10_1 bottle.
To show the formula before removal run:
git -C "$(brew --repo homebrew/core)" show d20fe73^:Formula/cassandra.rb
If you still use this formula consider creating your own tap:
http://docs.brew.sh/How-to-Create-and-Maintain-a-Tap.html
Please I need solution "how to get back these .rb files?" or "any other alternative way to install cassandra".

Install directly from GitHub as mentioned here -
How to restore brew formula after I rm it
brew install https://github.com/Homebrew/homebrew-core/tree/master/Formula/cassandra.rb

Try this command to bring back all of deleted files.
Note: This command will revert all change in $(brew --repo homebrew/core)
cd $(brew --repo homebrew/core) && git reset --hard origin/master
Homebrew uses git internally, so use git commands to repair some problem.

Related

brew tap facebook/fb results in Fetching error

I try to update Homebrew as usual. Recently when I issue the command brew update, the following error occurs:
Error: Fetching /usr/local/Homebrew/Library/Taps/facebook/homebrew-fb failed!
The Tap is associated with the software Buck, which I need for development.
I further investigate the issue by following the installation instruction in the Buck official website, I issue the command again:
% brew tap facebook/fb
==> Unshallowing facebook/fb
fatal: couldn't find remote ref refs/heads/master
Error: Failure while executing; `git fetch --unshallow` exited with 128.
Apparently, the Git source has problems. I try to "untap" it:
% brew untap facebook/fb
Error: Refusing to untap facebook/fb because it contains the following installed formulae or casks:
buck
No luck. How can I resolve this problem?
This error is the result of Facebook renaming the branch master to main.
To fix this, first change into Homebrew's local tap folder:
cd /usr/local/Homebrew/Library/Taps/facebook/homebrew-fb
Then, run the following Git commands to update the local repo:
git branch --unset-upstream
git config remote.origin.fetch '+refs/heads/main:refs/remotes/origin/main'
git fetch --prune origin
git branch -m main
git branch -u origin/main
git remote set-head origin -a
Finally, remove the no longer needed master ref (optional):
rm .git/refs/remotes/origin/master
That's it, you should now be able to successfully run brew update.

Home Brew install package getting could not resolve HEAD to a revision

I just installed the latest homebrew with version Homebrew 2.7.3. I have git pre-install on my Mac OS, and I was trying to install brew install git-crypt & brew install git-gui and getting an error on fatal: Could not resolve HEAD to a revision. It looks like it failed on any packages.
==> Searching for similarly named formulae...
Error: No similarly named formulae found.
Error: No available formula or cask with the name "git-crypt".
==> Searching for a previously deleted formula (in the last month)...
Error: No previously deleted formula found.
==> Searching taps on GitHub...
Error: No formulae found in taps.
I tried uninstall then re-install homebrew using their command line : https://github.com/homebrew/install#uninstall-homebrew
By running brew doctor, I am getting some warnings :
Warning: "config" scripts exist outside your system or Homebrew directories.
`./configure` scripts often look for *-config scripts to determine if
software packages are installed, and which additional flags to use when
compiling and linking.
Having additional scripts in your path can confuse software installed via
Homebrew if the config script overrides a system or Homebrew-provided
script of the same name. We found the following "config" scripts:
/Library/Frameworks/Python.framework/Versions/3.8/bin/python3-config
/Library/Frameworks/Python.framework/Versions/3.8/bin/python3.8-config
Warning: Some taps are not on the default git origin branch and may not receive
updates. If this is a surprise to you, check out the default branch with:
git -C $(brew --repo homebrew/core) checkout master
I checked this directory
/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core
and realize there's no Formula folder.
Any help would be appreciate.
I had this error and solved with
git -C $(brew --repo homebrew/core) checkout master

Homebrew Mac Update Issues

This is something that I've noticed starting about 2 days ago. In my past experience, Homebrew would always have daily updates. I would always type the command brew update and voila, there would be packages that would be updated/deleted and Homebrew would display what changed. I also noticed that if I didn't update Homebrew for more than a day, I would get the following notice:
Homebrew hasn't been updated in the last 24 hours. That's a long time in brew land. Type 'brew update.
However, the last time I updated Homebrew on my Mac was on August 10, 2016. Today is August 14, 2016 and when I type brew update, it tells me that everything is already up-to-date, even though I haven't updated Homebrew in 4 days. The update notice in brew doctor also does not show-up. I have not modified Homebrew in any way throughout this whole debacle.
Is there a solution to this Homebrew updating issue or does Homebrew not have daily updates anymore?
According to https://github.com/Homebrew/brew#update-bug
If Homebrew was updated on Aug 10-11th 2016 and brew update always says Already up-to-date. you need to run
cd $(brew --repo); git fetch; git reset --hard origin/master; brew update
Homebrew is basically a git directory, so you can cd into the directory and perform a git fetch followed by a git pull
If you are on default config:
cd /usr/local && git pull origin master
Please run to debug what happens when update
brew update --debug --verbose
brew update --force
My reference from this comment

Accidentally delete /usr/bin/git file and now I cannot work with git on the terminal

I had a problem with git on my machine and I accidentally deleted the /usr/bin/git from my system.
My git was installed through the XCode Command Line Tools and I cannot find a way to reinstall it.
The git was not uninstalled, the git file was removed.
Is there a way from XCode or somewhere else to reinstall the command line tools? or somewhere Where I can get the original git file to add to /usr/bin again?
THanks
sudo cp /Applications/Xcode.app/Contents/Developer/usr/bin/git /usr/bin/git
I don't know why /usr/bin/git isn't just a symlink to that file, but on my system it's a separate (identical) copy.

Error while trying to update brew package manager

I tried to update brew:
sudo brew update
But I got this error:
error: Your local changes to the following files would be overwritten by merge:
Listing a lot of files
Error: Failed while executing git pull http://github.com/mxcl/homebrew.git master
Any idea what is going wrong?
There was a bug in Homebrew that was fixed just a few days ago. To fix the bug you can run git reset --hard FETCH_HEAD inside your Homebrew installation. Since that won't fix files that are already seen as modified you can also run git checkout Library to replace your checkout with the latest files. (That wipes all edits so take appropriate measures with any you made.)
The accepted answer is correct but incomplete. If you are getting the error of
error: The following untracked working tree files would be overwritten by merge:
Then go to your terminal and run these commands
cd /usr/local
Then
git reset --hard FETCH_HEAD
Then
git checkout Library
That should get everything in order. Then run
brew update
Let me add: cd /usr/local/git
and then run git reset --hard FETCH_HEAD
go to your terminal and run these commands
cd /usr/local
sudo git reset --hard FETCH_HEAD
sudo git checkout Library
For those of you using OS X El Capitan, your problem may be System Integrity Protection.
If /usr/local exists already, run the following in Terminal:
sudo chown -R $(whoami):admin /usr/local
If /usr/local does not exist:
First, try to create /usr/local the normal way:
sudo mkdir /usr/local && sudo chflags norestricted /usr/local && sudo chown -R $(whoami):admin /usr/local
If you see permission issues instead try:
Reboot into Recovery mode (Hold Cmd+R on boot) & access the Terminal.
In that terminal run: csrutil disable
Reboot back into OS X
Open your Terminal application and execute the line from just above
Reboot back into Recovery Mode & access the Terminal again.
In that terminal execute: csrutil enable
Reboot back into OS X & you'll be able to write to /usr/local & install Homebrew.
Out of no reason (or at least no one I'd understand) the repository in /usr/local (which is the brew install!) lost its remote repository. So, neither a git reset nor a git pull and for sure no brew update would work.
How do you know that happened? Check /usr/local/.git/config whether there are some lines like the following:
[remote "origin"]
url = http://github.com/mxcl/homebrew.git
fetch = +refs/heads/*:refs/remotes/origin/*
If not do as follows:
cd /usr/local
git remote add origin http://github.com/mxcl/homebrew.git
git pull origin master

Resources