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 が引数に明確にあるのに、なぜモジュールが私に、 $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 に答える