Wednesday, October 31, 2007

Git/git-svn on Mac OS X Tiger (Macbook)

Though Git is complex to use I hope it will solve most of my version merge problems. I have used svk (a distributed version tool written in perl built on top of SVN and the SVN perl bindings) before and it is easy to use after creating a basic workflow (which may be slightly hard for a novice svn or CVS user). Unfortunately it dies with complex merge situations. It happens mainly if there is too much reorganization in the main trunk compared to your local branch. For example I worked/work (i try to work whenever I can but always get stupefied by the merge issues.) on an open source project called Cosmo - now renamed as Chandler server - it is actively developed and the trunk undergoes a huge change quite often. The merge interface of svk was really nice and I used it to keep merging changes from the trunk to my local branch. I also had my local branch merged to my own svn sandbox so that if my system crashes I can restore using my svn sandbox :). My entire workflow is documented at
http://chandlerproject.org/bin/view/Journal/SvkUsage

Now I got my almost new Macbook (repaired using Apple support) without any Linux (as of now) - I thought I will have most of the unix OSS goodies using Macports and Fink :). Git was one of my most wanted tool and I thought of installing it soon to get started with a few projects. As some of the websites pointed git install did not work using fink.
I did
# fink install git
and was greeted with some dependency error messages. I also tried
#fink selfupdate
asking me a lot of questions and taking a lot of time :(

#fink install git
again some dependency error message :(.

I always heard of Macports and wanted to give it a try. But installing Macports required installing XCode available through ADC, which requires a login. I first installed Macports without installing XCode hoping that it will work, but later realized that Macports needs a compiler as does any port based system. I have used Gentoo port based system and understood that everything is built using source and thus will require a compiler.

I downloaded the 3.0 version of XCode, but found that XCode 3.0 does not work with OS X 10.4 Tiger and is meant for leopard. I then downloaded the 2.5 version (around 1 GB download size) and installed it successfully. I could then issue port commands :)

# sudo port selfupdate

#sudo port install git-core

printed lot of stuff like downloading, building, etc taking a lot of time for the compilation
and Installation was a success :)

Happy with the success I typed
# git
it showed me the usage
I then typed
#git-svn
It said the command could not be found :(. A google search of git-svn on Mac showed me to use the command:
#sudo port install git +svn

That fetched a few more files, did some compilations, installations taking lots of time and I got an error that git-core is already installed. Obviously! But I wished the system was smarter and just installed git-svn.
I tried
#git-svn
and was greeted with the same command not found error.
I did see that the port system had two entries for git and I had to uninstall all git-core
# sudo port uninstall git-core @1.5.3.4_0+doc_svn
# sudo port uninstall git-core

Then I did a
#sudo port install git +svn

I tried
#git-svn
and yes I did see it was installed but the perl module had some missing dependencies. The module called Error.pm. I searched that package in port - but it was of no use and so I tried CPAN.
# sudo perl -MCPAN -e 'install Error'

It asked me a lot of questions - some missing programs which I installed either using fink or port. Both taking a lot of time and thus patience.
# sudo port install lynx
# sudo fink install wget
The path for port based installations was /opt/local - so I had to specify /opt/local/bin for the path of lynx binary.
For fink the path is /sw/ - so I had to specify /sw/bin for the path of wget binary.

You could use a single package management system to install the packages. I tried fink thinking that it was more like apt-get - but no it was getting all the deb's but I think they are source debs since I could see the output of configure, make.

The other package required by CPAN was ncftpget - both fink and ports did not have those packages :(. I just skipped that step.
Then I needed ncftp - ports had the package - So I did a
# sudo port install ncftp
and the next one
# sudo port install gpg-agent
But that did not give me the gpg binary and there was no gpg package in the default macports :(. I just skipped all the questions by pressing enter continuously. I got the Error.pm module installed :).
I then got an SVN/Core.pm not found error when I tried to run git-svn.

I first tried setting the PERL5LIB to my macports version of svn perl library and I got some weird error regarding some core bundler dependency. After struggling a bit I finally removed all git and svn from both Macports and fink. Downloaded git from kernel.org - compiled and installed it the unix way :)
# wget http://kernel.org/pub/software/scm/git/git-1.5.3.5.tar.bz2
# tar -jxvf git-1.5.3.5.tar.bz2
# cd git-1.5.3.5
# ./configure --prefix=/usr
# make && sudo make install


I followed http://speirs.org/2007/07/22/getting-git-svn-working-on-the-mac/ and downloaded the svn package precompiled with all the language binding. After installing the dmg file, I had to set PERL5LIB to /usr/local/lib/svn-perl.

I got git-svn working finally :).


I still miss the apt-get based installation in Debian systems which just installs the binary and is very fast. Ofcourse port based system has its own benefits like better optimized binary, etc - but it would be really frustrating to wait for 1-2 hours for a program to be installed :(.

6 comments:

Paulp said...

Thanks -- this writeup saved me a lot of time. Installed the precompiled Subversion package (1.4.6). This version loads language bindings for java, perl, ruby and python, but only installs the java links, so I needed to set PERL5LIB to '/opt/subversion/lib/svn-perl/'.

Then installed git 'the UNIX way' as you described and everything worked. Very straightforward. Thanks.

Anonymous said...

Thanks for this. One minor correction:

sudo port install git +svn
should be:
sudo port install git-core +svn

Anonymous said...

You should just be able to do: sudo port install git-core +svn

You guys should try Porticus, as it's a good GUI for MacPorts and can make life easier :)

Skeeterbug said...
This comment has been removed by the author.
Anonymous said...
This comment has been removed by a blog administrator.
Anonymous said...

http://git-scm.com/ embraces the http://code.google.com/p/git-osx-installer/downloads/list?can=3

By using this installer you save your self's the time and effort. And git-svn works out of the box with this one.