Git :: Repository:使用未初始化的值$ git_dir

时间:2013-09-03 06:02:33

标签: git perl cpan

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

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

任何提示?

1 个答案:

答案 0 :(得分:1)

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

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

my $git_path = $ENV{HOME} . '/gitstuff/repo/sandbox/.git';