0

我刚刚为我Git::Repository在 solaris 服务器上安装了我的系统管理员。我写了一个小测试脚本,以检查模块的基本功能是否正常工作并遇到此错误:

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

我的代码:

  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;

我只是不明白,为什么模块告诉我 $git_dir 是未定义的,而它显然存在于参数中。此外,该目录肯定存在。

bash-3.2$ pwd
~/gitstuff/repo/sandbox/.git

有什么提示吗?

4

1 回答 1

1
my $git_path = '~/gitstuff/repo/sandbox/.git';

必须是有效路径,并~应替换为

my $git_path = $ENV{HOME} . '/gitstuff/repo/sandbox/.git';
于 2013-09-03T06:35:54.410 回答