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.