my $git_path = '~/gitstuff/repo/sandbox/.git';
must be a valid path, and ~
should be replaced by
my $git_path = $ENV{HOME} . '/gitstuff/repo/sandbox/.git';
Question
I've just had my sysadmin install Git::Repository
on a solaris-server for me. I wrote a little test-script, to check if the basic functionality of the module is working and came across this error:
Use of uninitialized value $git_dir in -d at /usr/local/lib/perl5/site_perl/5.12.3/Git/Repository.pm line 97.
Use of uninitialized value $git_dir in concatenation (.) or string at /usr/local/lib/perl5/site_perl/5.12.3/Git/Repository.pm line 97.
directory not found: at ./list_commits.pl line 28
My code:
1 #!/usr/local/bin/perl -w
2 use strict;
3
4 use Git::Repository;
5 use Data::Dumper;
6 my $git_path = '~/gitstuff/repo/sandbox/.git';
7 my $repo = Git::Repository->new(
8 work_tree => $git_path
9 );
10 die Dumper $repo;
I just don't get it, why the module tells me, that $git_dir is undefined, when it's clearly there in the arguments. And in addition, the directory definitely exists.
bash-3.2$ pwd
~/gitstuff/repo/sandbox/.git
Any hints?
Solution
my $git_path = '~/gitstuff/repo/sandbox/.git';
must be a valid path, and ~
should be replaced by
my $git_path = $ENV{HOME} . '/gitstuff/repo/sandbox/.git';