20 September 2014

More Yak Shaving to Install Git Via MacPorts But With MacOS X Mavericks

After performing a fresh install of MacOS X Mavericks on two computers recently. Because of the reinstall of the OS, I also had to reinstall a bunch of other tools including git. In doing so, I realized that the configurations that I had in my old .bash_profile would no longer work correctly and so I had to update the location of a couple files. 

I blogged about this previously so I had already done some research about installing MacPorts on a computer and I knew that I'd need to install the command-line tools for XCode first. So I installed XCode first using the App Store and then followed the instructions to install the XCode command-line tools. Once these were installed, then I was able to proceed with the installation of MacPorts. 

So I downloaded and installed MacPorts, ran sudo port selfupdate followed by sudo port install bash to get the latest version of bash. So that the OS can make use of this newer version of bash, I added it to the On MacOS X, I added the path to this newer version of bash to the /etc/shells file. To actually make use of this updated version of bash, I had to make my terminal aware of it. I always use iterm2 instead of the Apple terminal, it's just so much more powerful. So I changed my profile in iterm2 to launch this version of bash by adding the bash login command to be run when iterm2 opens a new terminal, /opt/local/bin/bash -l. Now when iterm2 starts up, it logs in to this newer version of bash automatically for me. Now I'm ready to install the git tools. 

To install git, I run the following command in the terminal that I've always run to install git via MacPorts: 
Unfortunately this was unexpected, but the answer is right there in the error -- instead of installing git-core, just install git. So I ran the command again with a different name for git:
This got further but threw another error about the readline utility, so I had to force activate the readline utility. Beyond that, everything installed correctly.

However, the git bash completion didn't seen to work. I was seeing the following error from my .bash_profile when the bash prompt was getting set up:
bash: __git_ps1: command not found
It turns out, because the name of git in MacPorts was changed from git-core to just git, the paths to some of the git bash completion had changed as well. All I really had to do was update my .bash_profile from this:
/opt/local/share/git-core/contrib/completion/git-completion.bash
to this:
/opt/local/share/git/contrib/completion/git-completion.bash
and everything worked correctly.

No comments:

Post a Comment