Installing previous versions of a formula with brew extract - homebrew

Due to a problem with the Subversion 1.13 Brew formula I was installing an older revision of the formula:
brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/0c3d786402ad7d9dd5eb6907e3ed3f2525a0472d/Formula/subversion.rb
That gives a warning:
Warning: Calling Installation of subversion from a GitHub commit URL is deprecated! Use 'brew extract subversion' to stable tap on GitHub instead.
The suggestion is the same as this tip.
Now, I'd like to do this properly using brew extract subversion rather than using the deprecated commit URL. I'd like to install Subversion 1.13_5 on some computers, but Subversion 1.14 is the latest formula.
I need to do something like this: brew extract --version 1.13.0_5 subversion <tap>.
The way I understand this I should:
Create an empty repository for my versioned formulas
Add the repository as a tap and initialize it
Extract the versioned formula
Commit and push the formula?
I created an empty repository, then:
$ brew tap rjollos/homebrew-versioned
Cloning into '/usr/local/Homebrew/Library/Taps/rjollos/homebrew-versioned'...
warning: You appear to have cloned an empty repository.
Tapped (16 files, 22.2KB).
$ brew tap-new rjollos/homebrew-versioned
==> Created rjollos/versioned
/usr/local/Homebrew/Library/Taps/rjollos/homebrew-versioned
$ brew extract --version '1.13.0_5' subversion rjollos/homebrew-versioned
==> Searching repository history
Warning: Calling 'devel' blocks in formulae is deprecated! Use 'head' blocks or #-versioned formulae instead.
Please report this issue to the homebrew/core tap (not Homebrew/brew or Homebrew/core), or even better, submit a PR to fix it:
/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/subversion.rb:16
Warning: Calling 'devel' blocks ... (repeats about a dozen times)
Error: subversion: undefined method `sha1' for #<SoftwareSpec:0x00007fceaf144490>
I think I'm doing several things wrong, but mainly I'm unsure why brew extract doesn't work. Also, is there a better way to create a new repository and populate it with the template files for a new tap?
$ brew --version
Homebrew 2.4.4-19-ge09802b
Homebrew/homebrew-core (git revision 5ee797; last commit 2020-07-07)
Homebrew/homebrew-cask (git revision 837ac; last commit 2020-07-08)

Taps can be created locally without actual github repository. Here is general example:
TAP=... # <org>/<repo>, for example "my-org/homebrew-old"
MODULE=... # name of module you want to install, e.g. "hugo"
VERS=... # version of $MODULE you want to install, e.g., "0.80.0"
brew tap-new $TAP
brew extract --version $VERS $MODULE $TAP
brew install $TAP/$MODULE#$VERS

Still not sure this is the best way to create a new tap. I created homebrew-repo on my GitHub, then added the tap, then initialized the tap using tap-new.
$ TAP=rjollos/homebrew-repo
$ TAP_PATH=$(brew --repository)/Library/Taps/$TAP
$ brew tap $TAP
==> Tapping rjollos/repo
Cloning into '/usr/local/Homebrew/Library/Taps/rjollos/homebrew-repo'...
warning: You appear to have cloned an empty repository.
Tapped (16 files, 22.2KB).
$ brew tap-new $TAP
==> Created rjollos/repo
/usr/local/Homebrew/Library/Taps/rjollos/homebrew-repo
$ cd $TAP_PATH
$ git add .
$ git commit -m "Initialized with template files"
[master (root-commit) c7c4bed] Initialized with template files
2 files changed, 29 insertions(+)
create mode 100644 .github/workflows/main.yml
create mode 100644 README.md
$ git remote -v
origin https://github.com/rjollos/homebrew-repo (fetch)
origin https://github.com/rjollos/homebrew-repo (push)
Extract the versioned formula:
$ brew extract --version 1.13.0 subversion $TAP
==> Searching repository history
==> Writing formula for subversion from revision dab5452 to:
/usr/local/Homebrew/Library/Taps/rjollos/homebrew-repo/Formula/subversion#1.13.0.rb
Add the formula:
$ cd $TAP_PATH
$ git add Formula
$ git commit -m "Add Subversion 1.13 formula"
1 file changed, 203 insertions(+)
create mode 100644 Formula/subversion#1.13.0.rb
$ git push
Enumerating objects: 10, done.
Counting objects: 100% (10/10), done.
Delta compression using up to 8 threads
Compressing objects: 100% (7/7), done.
Writing objects: 100% (10/10), 3.99 KiB | 2.00 MiB/s, done.
Total 10 (delta 0), reused 0 (delta 0), pack-reused 0
To https://github.com/rjollos/homebrew-repo
* [new branch] master -> master

I tried brew install <url> approach, seems working well for me?
installation log:
$ brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/0c3d786402ad7d9dd5eb6907e3ed3f2525a0472d/Formula/subversion.rb
Warning: Calling Installation of subversion from a GitHub commit URL is deprecated! Use 'brew extract subversion' to stable tap on GitHub instead.
######################################################################## 100.0%
==> Downloading https://homebrew.bintray.com/bottles/subversion-1.13.0_5.mojave.bottle.tar.gz
Already downloaded: /Users/rchen/Library/Caches/Homebrew/downloads/6c15ae92fb6a09985f1679367588188829b69a4dbc53bb324597fb9fdf588d9e--subversion-1.13.0_5.mojave.bottle.tar.gz
Warning: subversion 1.14.0_2 is available and more recent than version 1.13.0_5.
==> Pouring subversion-1.13.0_5.mojave.bottle.tar.gz
==> Caveats
svntools have been installed to:
/usr/local/opt/subversion/libexec
The perl bindings are located in various subdirectories of:
/usr/local/opt/subversion/lib/perl5
You may need to link the Java bindings into the Java Extensions folder:
sudo mkdir -p /Library/Java/Extensions
sudo ln -s /usr/local/lib/libsvnjavahl-1.dylib /Library/Java/Extensions/libsvnjavahl-1.dylib
Bash completion has been installed to:
/usr/local/etc/bash_completion.d
==> Summary
🍺 /usr/local/Cellar/subversion/1.13.0_5: 234 files, 30.3MB
Removing: /Users/rchen/Library/Caches/Homebrew/subversion--1.13.0_5.mojave.bottle.tar.gz... (8.6MB)
version check
$ svn --version
svn, version 1.13.0 (r1867053)
compiled Apr 17 2020, 12:01:27 on x86_64-apple-darwin18.7.0
Copyright (C) 2019 The Apache Software Foundation.
This software consists of contributions made by many people;
see the NOTICE file for more information.
Subversion is open source software, see http://subversion.apache.org/
The following repository access (RA) modules are available:
* ra_svn : Module for accessing a repository using the svn network protocol.
- with Cyrus SASL authentication
- handles 'svn' scheme
* ra_local : Module for accessing a repository on local disk.
- handles 'file' scheme
* ra_serf : Module for accessing a repository via WebDAV protocol using serf.
- using serf 1.3.9 (compiled with 1.3.9)
- handles 'http' scheme
- handles 'https' scheme
The following authentication credential caches are available:
* Mac OS X Keychain

Related

Anyone else get this error "Error: invalid option: --with-passenger"

Can not get NGINX to install with passenger
Following the steps you are supposed to...
brew install passenger
Then you run the following command...
brew install nginx --with-passenger
But I get:
Error: invalid option: --with-passenger
Could not find any resources about this online, so asking here.
$ brew install nginx --with-passenger
Usage: brew install [options] formula
Install formula.
formula is usually the name of the formula to install, but it can be specified
in several different ways.
-d, --debug If brewing fails, open an interactive
debugging session with access to IRB or a
shell inside the temporary build directory
--env If std is passed, use the standard build
environment instead of superenv.If super
is passed, use superenv even if the formula
specifies the standard build environment.
--ignore-dependencies Skip installing any dependencies of any
kind. If they are not already present, the
formula will probably fail to install.
--only-dependencies Install the dependencies with specified
options but do not install the specified
formula.
--cc Attempt to compile using provided
compiler. compiler should be the name
of the compiler's executable, for instance
gcc-7 for GCC 7. In order to use LLVM's
clang, use llvm_clang. To specify the
Apple-provided clang, use clang. This
parameter will only accept compilers that
are provided by Homebrew or bundled with
macOS. Please do not file issues if you
encounter errors while using this flag.
-s, --build-from-source Compile the specified formula from source
even if a bottle is provided. Dependencies
will still be installed from bottles if
they are available.
--force-bottle Install from a bottle if it exists for the
current or newest version of macOS, even if
it would not normally be used for
installation.
--include-test Install testing dependencies required to
run brew test.
--devel If formula defines it, install the
development version.
--HEAD If formula defines it, install the HEAD
version, aka. master, trunk, unstable.
--fetch-HEAD Fetch the upstream repository to detect if
the HEAD installation of the formula is
outdated. Otherwise, the repository's HEAD
will be checked for updates when a new
stable or development version has been
released.
--keep-tmp Don't delete the temporary files created
during installation.
--build-bottle Prepare the formula for eventual bottling
during installation.
-f, --force Install without checking for previously
installed keg-only or non-migrated
versions.
-v, --verbose Print the verification and postinstall
steps.
--display-times Print install times for each formula at the
end of the run.
-i, --interactive Download and patch formula, then open a
shell. This allows the user to run
./configure --help and otherwise
determine how to turn the software package
into a Homebrew package.
-g, --git Create a Git repository, useful for
creating patches to the software.
-h, --help Show this message.
Error: invalid option: --with-passenger
This is supposed to work... so yeah.
A late answer. Obviously the documentation on the passenger site is outdated at time of this writing.
According to phusion's github site
https://github.com/phusion/passenger/issues/2187#issue-416881033
the config option --nginx-with-passenger is not valid anymore.
Instead do:
brew install nginx passenger
Addendum:
When using google search for results currently the old page comes up at the top of the list. Here's the currently maintained page with the accurate information:
https://www.phusionpassenger.com/docs/advanced_guides/install_and_upgrade/nginx/install/oss/osx.html

There are older versions of Google Cloud Platform tools: Docker

After updating gcloud I get this warning, but how do I do it(Should I remove Docker)?
WARNING: There are older versions of Google Cloud Platform tools on your system PATH.
Please remove the following to avoid accidentally invoking these old tools:
/Applications/Docker.app/Contents/Resources/bin/kubectl
I have this in my .zshrc:
# The next line updates PATH for the Google Cloud SDK.
if [ -f '/Users/<NAME>/google-cloud-sdk/path.zsh.inc' ]; then source '/Users/<NAME>/google-cloud-sdk/path.zsh.inc'; fi
# The next line enables shell command completion for gcloud.
if [ -f '/Users/<NAME>/google-cloud-sdk/completion.zsh.inc' ]; then source '/Users/<NAME>/google-cloud-sdk/completion.zsh.inc'; fi
[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh
This happens because docker-for-mac installs a bin for kubectl, and gcloud-sdk also installs another bin with gcloud components install kubectl.
My recommendation is to uninstall kubectl as component from gcloud, overwrite the symlink from docker-for-mac, and only use the homebrew installed bin.
Try this commands:
gcloud components remove kubectl
brew install kubernetes-cli
brew link --overwrite kubernetes-cli
TLDR
/usr/local/bin/kubectl is a link installed by Docker: ls -l /usr/local/bin/kubectl => /usr/local/bin/kubectl -> /Applications/Docker.app/Contents/Resources/bin/kubectl. Removing the link has no side effects and solves the conflict:
rm /usr/local/bin/kubectl
Justification
The conflict is with the Docker-provided version of kubectl so it makes sense to check what Docker docs have to say about it. https://docs.docker.com/desktop/kubernetes/#use-the-kubectl-command
Extract:
If you installed kubectl using Homebrew, or by some other method, and experience conflicts, remove /usr/local/bin/kubectl.
Here is my case you can refer to. After running gcloud components update, I got this warning:
WARNING: There are older versions of Google Cloud Platform tools on your system PATH.
Please remove the following to avoid accidentally invoking these old tools:
/usr/local/Cellar/kubernetes-cli/1.10.2/bin/kubectl
I check this tool using brew list
☁ issue [master] brew list
coreutils gdbm git-lfs icu4c kops kubectx libpng mtr openssl python#2 sqlite tree wxmac
erlang geoip git-redate jpeg kube-ps1 kubernetes-cli libtiff node pcre readline telnet watchman
After reading the doc. I decided to uninstall kubernetes-cli and its dependencies kops, kube-ps1, and kubectx to avoid the conflicts.
☁ issue [master] brew uninstall kops kube-ps1 kubectx
Uninstalling /usr/local/Cellar/kops/1.9.0... (5 files, 129.8MB)
Uninstalling /usr/local/Cellar/kube-ps1/0.6.0... (6 files, 29.0KB)
Uninstalling /usr/local/Cellar/kubectx/0.5.0... (12 files, 27.8KB)
☁ issue [master] brew uninstall kubernetes-cli
Uninstalling /usr/local/Cellar/kubernetes-cli/1.10.2... (178 files, 52.8MB)
☁ issue [master] gcloud components update
All components are up to date.
This warning is gone.
I just went into the Docker file's bin folder and moved the kubectl to the trash.
Do echo $PATH and check which folder takes precedence. In my case it is like .../Users/myname/google-cloud-sdk/bin:/usr/local/bin:/usr/bin:.... Here the kubectl in gcloud is actually before the kubectl from Docker Desktop (which is in /usr/local/bin/kubectl) so there is no problem. If this is also your case you don't need to do anything.
Of course, if you want to completely remove confusion you can just delete the link /usr/local/bin/kubectl -> /Applications/Docker.app/Contents/Resources/bin/kubectl, or rename it.
Update:
In the recent docker desktop releases they actually provided another link /usr/local/bin/kubectl.docker -> /Applications/Docker.app/Contents/Resources/bin/kubectl to differentiate it from other kubectl so it is not a bad idea to just simply delete the link /usr/local/bin/kubectl -> /Applications/Docker.app/Contents/Resources/bin/kubectl

Adding a variant to an existing homebrew formula?

I'd like to modify the dtc formula to build a specialized version of dtc used with the Beaglebone Black (and other device-tree ARM boards). The problem is multi-fold. The dtc formula provides bottled versions, and installed 1.4.0. I want to install a version that comes from newer sources, but not the absolute latest, and applies a patch available elsewhere. I can build this manually on OS X, but I don't know the best way to make it available in homebrew.
I'd like to make it a variant. Either an entirely separate formula, or something within the current formula that can be selected with a command-line parameter. But I'm not well-versed enough in brew to know how best to do this.
I tried creating new formula called "dtc-dyn" but it doesn't like dashes in the name.
I'd also like to make it a bottle, for others' convenience, but that seems more complicated.
I tried just modifying the current dtc and removing all the bottle stuff, then modifying the URL, version, and adding system steps. But some of the operations fail (that seem to work when run from the original build script):
def install
git_sha = "f6dbc6ca9618391e4f30c415a0a09b7af35f7647"
system "git checkout master -f"
system "git pull"
system "git checkout #{git_sha} -b #{git_sha}-build"
system "git pull --no-edit https://github.com/pantoniou/dtc dt-overlays5"
system "make clean"
system "make all"
end
Sadly, this doesn't work:
$ brew install dtc
==> Cloning git://git.kernel.org/pub/scm/utils/dtc/dtc.git
Updating /Library/Caches/Homebrew/dtc--git
==> Checking out branch master
==> git checkout master -f
==> git pull
==> git checkout f6dbc6ca9618391e4f30c415a0a09b7af35f7647 -b f6dbc6ca9618391e4f30c415a0a09b7af35f7647-build
2015-09-21 00:22:37 -0700
git checkout f6dbc6ca9618391e4f30c415a0a09b7af35f7647 -b f6dbc6ca9618391e4f30c415a0a09b7af35f7647-build
fatal: reference is not a tree: f6dbc6ca9618391e4f30c415a0a09b7af35f7647
READ THIS: https://git.io/brew-troubleshooting
The original script can be found here.
Anyway, what's the best way to approach this? I think some kind of with-option, based on some of the example scripts, but I'm not sure how to avoid the bottle business. Thanks!
Second Approach
Okay, after more doc reading and experimenting, I'm trying this:
class Dtc < Formula
desc "Device tree compiler"
homepage "http://www.devicetree.org/"
url "https://mirrors.kernel.org/debian/pool/main/d/device-tree-compiler/device-tree-compiler_1.4.0+dfsg.orig.tar.gz"
mirror "https://mirrors.ocf.berkeley.edu/debian/pool/main/d/device-tree-compiler/device-tree-compiler_1.4.0+dfsg.orig.tar.gz"
sha256 "f5f9a1aea478ee6dbcece8907fd4551058fe72fc2c2a7be972e3d0b7eec4fa43"
version "1.4.0"
option "with-symbols", "Add symbols/fixup support (-# option)."
bottle…
if build.with? "symbols"
url "http://git.kernel.org/pub/scm/utils/dtc/dtc.git", :revision => "f6dbc6ca9618391e4f30c415a0a09b7af35f7647"
system "git", "pull", "--no-edit", "https://github.com/pantoniou/dtc", "dt-overlays5"
end
def install
system "make"
system "make", "DESTDIR=#{prefix}", "PREFIX=", "install"
mv lib/"libfdt.dylib.1", lib/"libfdt.1.dylib"
end
end
Unfortunately, the git pull fails because it does that before cloning the git repo, and it's not in the right directory. I first considered patch do…, but it wasn't clear how to apply the patch via git pull. I tried this:
if build.with? "symbols"
url "http://git.kernel.org/pub/scm/utils/dtc/dtc.git", :revision => "f6dbc6ca9618391e4f30c415a0a09b7af35f7647"
patch do
system "git", "pull", "--no-edit", "https://github.com/pantoniou/dtc", "dt-overlays5"
end
end
But it still tries to do the git pull before cloning the repo and cding to it.

Installing Erlang/OTP 17.5 on OSX

The official install instructions say:
If you want to build the wx application, you will need to get
wxWidgets-3.0 (wxWidgets-3.0.0.tar.bz2 from
http://sourceforge.net/projects/wxwindows/files/3.0.0/) or get it from
github with bug fixes:
$ git clone --branch WX_3_0_branch git#github.com:wxWidgets/wxWidgets.git
Who wouldn't want bug fixes:
$ git clone --branch WX_3_0_branch git#github.com:wxWidgets/wxWidgets.git
Cloning into 'wxWidgets'...
fatal: Remote branch WX_3_0_branch not found in upstream origin
Does anyone know where the bug fix version is located?
Response to comment:
With all caps, I get:
$ git clone --branch WX_3_0_BRANCH git#github.com:wxWidgets/wxWidgets.git
Cloning into 'wxWidgets'...
ssh_exchange_identification: read: Connection reset by peer
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
For future searchers: in order to use github commands like above, you need to setup ssh keys for your computer. I had already done that, but for some reason it didn't work a few hours later. Firewall problems at my new location? I don't know. I moved to a different location/server from where I was getting the Connection reset by peer error, and then I created a new ssh key, and I was able to download and install wxWidgets. The git clone command just downloads the source, so you probably want to be at the ~/Downloads prompt when you issue that command. The Erlang install directions tell you how to install wxWidgets.
The branch in question is named WX_3_0_BRANCH — all uppercase.

Brew update failed: untracked working tree files would be overwritten by merge

Trying to update Homebrew with brew update I got the following error
error: The following untracked working tree files would be overwrittenby merge:
Library/Formula/argp-standalone.rb
Library/Formula/cocot.rb
Please move or remove them before you can merge.
Aborting
Updating e088818..5909e2c
Error: Failed while executing git pull origin refs/heads/master:refs/remotes/origin/master
I found a blog post by someone who experienced a similar problem after having installed Mountain Lion (which I did this week too). He explains how he removed the files referred to in the error message
I removed these files:
$ cd $(brew --prefix)
$ rm cocot.rb
However, removing these files didn't help with the brew update. Instead I had to manually update brew through git:
$ cd $(brew --prefix)
$ git fetch origin
$ git reset --hard origin/master
$ brew update
Already up-to-date.
Assuming those instructions are correct (which I maybe shouldn't assume), I tried to follow these instructions and do
$ cd $(brew --prefix)
$ rm cocot.rb
However, it said 'file doesn't exist' when I tried to rm cocot.rb
One thing I'm not sure about is the cd $(brew --prefix) Are those the exact words I type or do I have to replace prefix with something? the cd was successful, so I'm assuming it was correct -- it moved me into /usr/local, but there was no file to remove. Contents of /usr/local are
Cellar clamXav git mysql var Library doc heroku mysql-5.5.15-osx10.6-x86_64 README.md etc include rvm bin foreman lib share
At any rate, do you know how I can fix the 'brew update'
Update: After removing the files according to favoretti's instructions and trying chown -R <your_username> $(brew --prefix)/.git, I got the following error running brew update
error: The following untracked working tree files would be overwritten by merge:
Library/Aliases/gperftools
Library/Aliases/hashdeep
Library/Aliases/htop
Library/Aliases/nodejs
Library/Aliases/ocio
Library/Aliases/oiio
Library/Aliases/pgrep
Library/Aliases/pkill
Library/Aliases/qt4
Library/Aliases/twolame
Library/Aliases/wxwidgets
Library/Contributions/cmds/brew-aspell-dictionaries
Library/Contributions/cmds/brew-beer.rb
Library/Contributions/cmds/brew-dirty.rb
Library/Contributions/cmds/brew-graph
Library/Contributions/cmds/brew-grep
Library/Contributions/cmds/brew-leaves.rb
Library/Contributions/cmds/brew-linkapps.rb
Library/Contributions/cmds/brew-ls-taps.rb
Library/Contributions/cmds/brew-man
Library/Contributions/cmds/brew-md5-to-sha1
Library/Contributions/cmds/brew-mirror-check.rb
Library/Contributions/cmds/brew-pull.rb
Library/Contributions/cmds/brew-readall.rb
Library/Contributions/cmds/brew-server
Library/Contributions/cmds/brew-services.rb
Library/Contributions/cmds/brew-switch.rb
Library/Contributions/cmds/brew-test-bot.rb
Library/Contributions/cmds/brew-tests.rb
Library/Contributions/cmds/brew-unpack.rb
Library/Contributions/cmds/brew-which.rb
Library/Contributions/cmds/git
Library/Contributions/cmds/svn
Library/ENV/4.3/apr-1-config
Library/ENV/4.3/bsdmake
Library/ENV/4.3/c++
Library/ENV/4.3/c89
Library/ENV/4.3/c99
Library/ENV/4.3/cc
Library/ENV/4.3/clang
Library/ENV/4.3/clang++
Library/ENV/4.3/cpp
Library/ENV/4.3/g++
Library/ENV/4.3/gcc
Library/ENV/4.3/git
Library/ENV/4.3/i686-apple-darwin11-llvm-g++-4.2
Library/ENV/4.3/i686-apple-darwin11-llvm-gcc-4.2
Library/ENV/4.3/ld
Library/ENV/4.3/llvm-g++
Library/ENV/4.3/llvm-g++-4.2
Library/ENV/4.3/llvm-gcc
Library/ENV/4.3/llvm-gcc-4.2
Library/ENV/4.3/make
Library/ENV/4.3/mig
Library/ENV/4.3/sed
Library/ENV/4.3/svn
Library/ENV/4.3/xcrun
Library/ENV/libsuperenv.rb
Library/ENV/pkgconfig/leopard/libcrypto.pc
Library/ENV/pkgconfig/leopard/libcurl.pc
Library/ENV/pkgconfig/mountain_lion/libcurl.pc
Library/ENV/pkgconfig/mountain_lion/libexslt.pc
Library/ENV/pkgconfig/mountain_lion/libxml-2.0.pc
Library/ENV/pkgconfig/mountain_lion/libxslt.pc
Library/Formula/abcl.rb
Library/Formula/abcmidi.rb
Library/Formula/aiccu.rb
Library/Formula/akka.rb
Library/Formula/alac.rb
Library/Formula/alure.rb
Library/Formula/appledoc.rb
Library/Formula/arangodb.rb
Library/Formula/argp-standalone.rb
Library/Formula/argtable.rb
Library/Formula/autopano-sift-c.rb
Library/Formula/avian.rb
Library/Formula/avidemux.rb
Library/Formula/avro-cpp.rb
Library/Formula/aws-cloudsearch.rb
Library/Formula/aws-sns-cli.rb
Library/Formula/backupninja.rb
Library/Formula/bact.rb
Library/Formula/bam.rb
Library/Formula/basex.rb
Library/Formula/berkeley-db4.rb
Library/Formula/bind.rb
Library/Formula/blazeblogger.rb
Library/Formula/bochs.rb
Library/Formula/boost149.rb
Library/Formula/bsdconv.rb
Library/Formula/bsdmake.rb
Library/Formula/buildapp.rb
Library/Formula/bup.rb
Library/Formula/byacc.rb
Library/Formula/cadubi.rb
Library/Formula/camellia.rb
Library/Formula/casperjs.rb
Library/Formula/ccextractor.rb
Library/Formula/cconv.rb
Library/Formula/cdo.rb
Library/Formula/cdpr.rb
Library/Formula/cgvg.rb
Library/Formula/checkstyle.rb
Library/Formula/chordii.rb
Library/Formula/chruby.rb
Library/Formula/cifer.rb
Library/Formula/clhep.rb
Library/Formula/cntlm.rb
Library/Formula/cocot.rb
Library/Formula/cogl.rb
Library/Formula/collada-dom.rb
Library/Formula/crash.rb
Library/Formula/crossroads.rb
Library/Formula/crosstool-ng.rb
Library/Formula/css-crush.rb
Library/Formula/csync.rb
Library/Formula/ctemplate.rb
Library/Formula/curlftpfs.rb
Library/Formula/cutter.rb
Library/Formula/cvsutils.rb
Library/Formula/darkstat.rb
Library/Formula/darner.rb
Library/Formula/dart.rb
Library/Formula/dasm.rb
Library/Formula/debianutils.rb
Library/Formula/dfc.rb
Library/Formula/dgtal.rb
Library/Formula/dhcping.rb
Library/Formula/di.rb
Library/Formula/dmtx-utils.rb
Library/Formula/drip.rb
Library/Formula/dsniff.rb
Library/Fo
Aborting
Updating e088818..c1fbc29
Error: Failed while executing git pull origin refs/heads/master:refs/remotes/origin/master
You need to do the following:
cd $(brew --prefix)
rm Library/Formula/argp-standalone.rb
rm Library/Formula/cocot.rb
And then do the
git fetch origin
git reset --hard origin/master
brew update
Basically, to explain a bit more:
cd $(brew --prefix)
tells cd to change the directory to whatever brew --prefix will output.
If you try executing brew --prefix command you should see something in lines of:
brew --prefix
/usr/local
So the command would be in this case an equivalent of cd /usr/local.
Newer brew versions have formulae under its installation prefix and Library/Formula/, so that's where you need to look for those outdated/changed files.
Note, that if you changed those formulae yourself for a particular reason (like pinning a version) this action will revert them back to default ones and may produce unwanted effects.
#TedPennings noted in comments that this worked for him, but his sequence was:
chown everything to my_username:admin, ie, sudo chown -R ted:admin $(brew --prefix)
run the two git commands above,git fetch origin and git reset --hard origin/master
cd $(brew --prefix)
git reset --hard HEAD
brew update
This is caused by an old bug in the update code that has long since been fixed. However, the nature of the bug requires that you do the following:
cd $(brew --repository)
git reset --hard FETCH_HEAD
If brew doctor still complains about uncommitted modifications, also run this command:
cd $(brew --repository)
git clean -fd
$ cd $(brew --prefix)
$ git clean -fd
$ git reset --hard
$ sudo chown -R `whoami` `brew --prefix`
$ brew update
Note: steps 2&3 worked for me since I did step 5 before 4 before I got the error. The brew update before changing the owner of the folder caused the whole problem.
I had a similar issue where my brew package library got downloaded as a root user and then I was not able to run brew update as git would complain about not able to merge the file.
Solution was to do :-
sudo chown -R <user> /usr/local/Library
Resetting the brew repository should be the most efficient way if you don't mind to discard potential modifications on formulas you might have been applied:
$ cd `brew --prefix`
$ git fetch origin
$ git reset --hard origin/master
$ brew cleanup --force
$ brew update
I was able to fix this on my machine by adding admin group write (and setgid bit) permission at these paths:
sudo chmod -R g+ws /usr/local /Library/Caches/Homebrew
The s sets the group id on execution so that the write permissions aren't lost the next time a different admin user updates or upgrades Homebrew.
This answer is somewhat incomplete because when I try to do brew cleanup --force there is a permissions issue when Homebrew tries to remove content in /usr/local/Cellar/. (Unfortunately I'm not able to investigate this further at the moment.)
Another option is to just use git stash.
The brew update command performs a git pull, so if there are any changed files (or even file attributes, which happened to me when I changed permissions in the directory recursively) you have to somehow fix the conflicts. Using git stash is one way; it takes any changes and puts them aside so you effectively revert to the last updated repo version. The Homebrew 'location' is by default /usr/local and it installs as a git repository. You can look for a .git folder to see for yourself. I'm writing a homebrew uninstall script to be posted on my GitHub profile soon with more info.
sudo chown -R USER /usr/local/bin
note - for USER use command whom i.e. your username
sudo brew doctor
This approach may be simpler than some. It involves:
fixing a git issue so you can delegate management of changes to it again.
no manual moves of files or directories.
no manual adjustments of file or directory permissions.
Steps (with notes for those who want explanations):
cd $(brew --repository) // see Note 1 below
git remote add brew https://github.com/Homebrew/brew // see Note 2 below
git pull brew master // promising fast-forward report!
brew update // see Note 3 below
Overview:
From what I can tell, the actual cause of this issue is a change in the repo url. It's now brew and was brew.git. (Full up-to-date url: https://github.com/Homebrew/brew)
Note 1: This first command takes you from anywhere in your file structure to the correct directory. The directory structure is different for me than what others show above (Mac OS 10.11.16), but with this command, those differences should not matter.
Note 2: This second command adds the correct remote url to a new alias; I did so just in case this approach didn't accomplish what I wanted and I needed the previous address again. Since the new remote worked, I'll invite someone else to comment on simply changing the url aliased by origin. I'll happily update the answer to reflect what worked for you.
Note 3: This forth command has exactly the desired result: it reports a large number of updates, including the particularly nice report of "==> Migrated HOMEBREW_REPOSITORY to /usr/local/Homebrew!" (emphasis theirs).
This post helped me after updating to El Capitan. In my case, chown wasn't working ("zsh: command not found: chown"), so step 1 was adding this line to my .zshrc:
export PATH="$PATH:/usr/sbin"
I'd already tried several of the more popular answers above, so I'm pretty sure that git status was coming up clean by the time I pasted in the critical command from the blog post:
sudo chown $(whoami):admin /usr/local && sudo chown -R $(whoami):admin /usr/local
This should work.
1. cd `brew --prefix`
2. git fetch origin
3. git reset --hard origin/master
4. sudo brew update

Resources