Git svn for OS X – fix
filed in Uncategorized on Aug.22, 2008
So you have downloaded GIT for OS X from Google code. Everything works. Except when you try to use “git-svn”, you get the following error:
Can’t locate Term/ReadKey.pm in @INC (@INC contains ….
There are two things you can do. If you have the development tools (XCode) installed, then you can do as Larry shows, entering the following commands in Terminal:
perl -MCPAN -e shell install Term::ReadKey exit
But what if you, like me, don’t have the development suite installed (especially on server machines)? Here is where a little PERL hacking comes in. You open /usr/local/git/libexec/git-core/git-svn, and look for the following subroutine:
sub _read_password { my ($prompt, $realm) = @_; print STDERR $prompt; STDERR->flush; require Term::ReadKey; Term::ReadKey::ReadMode('noecho'); my $password = ''; while (defined(my $key = Term::ReadKey::ReadKey(0))) { last if $key =~ /[\012\015]/; # \n\r $password .= $key; } Term::ReadKey::ReadMode('restore'); print STDERR "\n"; STDERR->flush; $password; }
And you change it like this:
sub _read_password { my ($prompt, $realm) = @_; print STDERR $prompt; STDERR->flush; # require Term::ReadKey; # Term::ReadKey::ReadMode('noecho'); # my $password = ''; # while (defined(my $key = Term::ReadKey::ReadKey(0))) { # last if $key =~ /[\012\015]/; # \n\r # $password .= $key; # } # Term::ReadKey::ReadMode('restore'); # Rewrite by kkovacs # No Term::ReadKey installed my $password = ''; `stty -echo`; $password = <>; `stty echo`; $password =~ s/\s+$//; print STDERR "\n"; STDERR->flush; $password; }
Congratulations! Now you have a working git-svn for OS X Leopard.
April 6th, 2009 on 09:50
This helped me, thank you. I couldn’t get Term::Readkey to be picked up in the Perl5 path. My patch was slightly different though.
http://gist.github.com/90674
April 6th, 2009 on 18:27
Michael,
i’m happy if I helped you! :) This is why I posted this on the net.
June 26th, 2009 on 02:43
Thanks,
Works like a charm!