2
votes

I am attempting to upgrade git. I am running into a variation of what seems to be common pathing problem with upgrading git and the git version that comes installed with Xcode. I'm new to git, and fairly new to programming in general. Please keep that in mind, thanks.

I'm running OSX 10.9.5 and have Xcode 6.1.1.

I followed the instructions here: blog post.

When I run brew doctor I get a bunch of warnings:

Please note that these warnings are just used to help the Homebrew maintainers with debugging if you file an issue. If everything you use Homebrew for is working fine: please don't worry and just ignore them. Thanks!

Warning: Python is installed at /Library/Frameworks/Python.framework

Homebrew only supports building against the System-provided Python or a brewed Python. In particular, Pythons installed to /Library can interfere with other software installs.

Warning: Unbrewed dylibs were found in /usr/local/lib. If you didn't put them there on purpose they could cause problems when building Homebrew formulae, and may need to be deleted.

Unexpected dylibs: /usr/local/lib/libtcl8.6.dylib /usr/local/lib/libtk8.6.dylib

Warning: Unbrewed header files were found in /usr/local/include. If you didn't put them there on purpose they could cause problems when building Homebrew formulae, and may need to be deleted.

Unexpected header files: /usr/local/include/fakemysql.h /usr/local/include/fakepq.h /usr/local/include/fakesql.h /usr/local/include/itcl.h /usr/local/include/itcl2TclOO.h /usr/local/include/itclDecls.h /usr/local/include/itclInt.h /usr/local/include/itclIntDecls.h /usr/local/include/itclMigrate2TclCore.h /usr/local/include/itclTclIntStubsFcn.h /usr/local/include/mysqlStubs.h /usr/local/include/odbcStubs.h /usr/local/include/pqStubs.h /usr/local/include/tcl.h /usr/local/include/tclDecls.h /usr/local/include/tclOO.h /usr/local/include/tclOODecls.h /usr/local/include/tclPlatDecls.h /usr/local/include/tclThread.h /usr/local/include/tclTomMath.h /usr/local/include/tclTomMathDecls.h /usr/local/include/tdbc.h /usr/local/include/tdbcDecls.h /usr/local/include/tdbcInt.h /usr/local/include/tk.h /usr/local/include/tkDecls.h /usr/local/include/tkPlatDecls.h

Warning: Unbrewed .pc files were found in /usr/local/lib/pkgconfig. If you didn't put them there on purpose they could cause problems when building Homebrew formulae, and may need to be deleted.

Unexpected .pc files: /usr/local/lib/pkgconfig/tcl.pc /usr/local/lib/pkgconfig/tk.pc

Warning: Unbrewed static libraries were found in /usr/local/lib. If you didn't put them there on purpose they could cause problems when building Homebrew formulae, and may need to be deleted.

Unexpected static libraries: /usr/local/lib/libtclstub8.6.a /usr/local/lib/libtkstub8.6.a

Warning: /usr/bin occurs before /usr/local/bin This means that system-provided programs will be used instead of those provided by Homebrew. The following tools exist at both paths:

2to3
easy_install
easy_install-2.7
gcc-4.2

Consider setting your PATH so that /usr/local/bin occurs before /usr/bin. Here is a one-liner: echo export PATH='/usr/local/bin:$PATH' >> ~/.bash_profile

At first I ignored these errors as per the brew message at the beginning, but when I run brew upgrade git I get the following:

Error: No such file or directory - /usr/local/Cellar/git

After Googling the problem I found people had solved a similar problem (same error different path specified) by editing their bash.profile, so I ran the echo command

echo export PATH='/usr/local/bin:$PATH' >> ~/.bash_profile

I also tried

echo export PATH='/usr/local/Cellar/git:$PATH' >> ~/.bash_profile

and tried manually adding these export PATH commands to my .bash_profile using nano, but none of this seems to have helped.

Any help would be appreciated?

4

4 Answers

4
votes

So I was able to solve this problem by uninstalling git twice and then reinstalled the latest version of git. This removed both the pre-installed version of git and the one that I had installed, eliminating the pathing problem. I ran:

which git

and then ran sudo rm -rf /absolute/path/to/git

which deleted one of the git programs that had been installed. Then I ran both commands again, but the second time which git returned a different path that I used with the second sudo rm -rf /absolute/path/to/git. Finally, I installed git using brew.

Not rocket science but it seems to have worked.

2
votes

I assume you have some version of git already installed? (Type git --version or which git to check.) If you don't, then go ahead and let brew install git and you're done.

However, assuming you do already have git installed:

Option 1: If brew does not recognise the current git install

Overall this is a super quick fix... worked for me

Run $ brew upgrade git

If the result tells you not installed, then brew doesn't recognise the current installation... your fastest option is to let brew install from scratch:

  1. Rename your existing Apple-installed git (example)
  2. Let brew install the latest version via brew install git (example)

That step 1, re-naming the Apple-installed git, is just one way to avoid the conflict between Apple-installed Git and the new one you're installing via Homebrew. For a second example of this, see this other post on the blog you linked to for more: http://rayhightower.com/blog/2014/12/18/git-vulnerability-on-mac-os-x/

Option 2: Getting brew to recognise the git install you have

If you think the above is too clumsy leaving an old git install hanging out on your computer...

An alternative option might be to play with links? My initial attempt at brew link didn't work for me. I didn't try to solve via a symlink or by defining any $PATH. There's surely a neater option than simply abandoning the existing install, but Option 1 sufficed for me for today.

0
votes

This worked for me:

  1. Rename your existing Apple-installed git (https://stackoverflow.com/a/27646134)

  2. Fix brew's installation of git (No such keg: /usr/local/Cellar/git)

0
votes

By no means an expert but for me, I basically did:

  1. Backup original git directory
  2. Install Git with Homebrew
  3. Restart (or source) shell

~ > which git
/usr/bin/git
~ > sudo mv /usr/bin/git /usr/bin/git-original
~ > which git
git not found
~ > brew install git
~ > source /etc/profile
~ > git --version
git version 2.4.3