Skip to content

Dist::Zilla::Tester dies when run from a read-only working directory #698

@ppisar

Description

@ppisar

An example of Dist::Zilla::Tester dying when a test of Dist-Zilla-Plugin-Git is run from read-only location:

$ perl -I. t/tag.t 
1..8
Error in tempdir() using tmp/XXXXXXXXXX: Parent directory (tmp) does not exist at /usr/share/perl5/vendor_perl/Dist/Zilla/Tester.pm line 142.
# Looks like your test exited with 2 before it could output anything.

The cause is that Dist::Zilla::Tester defaults to ./tmp and "mkdir $tempdir_root " failure is not handled:

  around from_config => sub {
    my ($orig, $self, $arg, $tester_arg) = @_;

    confess "dist_root required for from_config" unless $arg->{dist_root};

    my $source = $arg->{dist_root};

    my $tempdir_root = exists $tester_arg->{tempdir_root}
                     ? $tester_arg->{tempdir_root}
                     : 'tmp';

    mkdir $tempdir_root if defined $tempdir_root and not -d $tempdir_root;

→   my $tempdir_obj = File::Temp->newdir(
      CLEANUP => 1,
      (defined $tempdir_root ? (DIR => $tempdir_root) : ()),
    );
    [...]

I recommend stop using ./tmp and leave selecting the temporary directory on File::Temp->newdir(). It's much smarter when finding a place for the temporary object. ./tmp is also insecure because an attacker can implant symlink of that name.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions