Skip to content

Directory-handling failure with absolute paths #36

@dmacks

Description

@dmacks

After upgrading my ExtUtils::Install from 2.18 to 2.22, 'make install' started failing for various other packages. For example, when the fink tries to install Locale-gettext-1.07 to the staging directory:

make install PREFIX=/sw INSTALLPRIVLIB=/sw/lib/perl5/5.18.2 INSTALLARCHLIB=/sw/lib/perl5/5.18.2/darwin-thread-multi-2level INSTALLSITELIB=/sw/lib/perl5/5.18.2 INSTALLSITEARCH=/sw/lib/perl5/5.18.2/darwin-thread-multi-2level INSTALLMAN1DIR=/sw/share/man/man1 INSTALLMAN3DIR=/sw/share/man/man3 INSTALLSITEMAN1DIR=/sw/share/man/man1 INSTALLSITEMAN3DIR=/sw/share/man/man3 INSTALLBIN=/sw/bin INSTALLSITEBIN=/sw/bin INSTALLSCRIPT=/sw/bin INSTALLSITESCRIPT=/sw/bin DESTDIR=/sw/build.build/root-locale-gettext-pm5182-1.07-1
"/usr/bin/arch" -x86_64 perl5.18 -MExtUtils::Command::MM -e 'cp_nonempty' -- gettext.bs /sw/build.build/locale-gettext-pm5182-1.07-1/Locale-gettext-1.07/blib/arch/auto/Locale/gettext/gettext.bs 644
Manifying 1 pod document
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
ERROR: Couldn't chdir to '/sw/build.build/locale-gettext-pm5182-1.07-1/Locale-gettext-1.07//sw/build.build/locale-gettext-pm5182-1.07-1/Locale-gettext-1.07/blib/arch/auto/Locale/gettext': No such file or directory
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 at /System/Library/Perl/5.18/File/Find.pm line 790.
make: *** [pure_site_install] Error 2

I narrowed it down to a regression in 2.18 -> 2.20, where the failure is triggered by a change in how an absolute path is handled. Notice the error message has a double-slash in the middle and then a full path beyond it. The intent is surely what follows that to be an absolute path, not a relative path to what comes before it.

The specific code change that triggers it is around line 753 in Install.pm, in code that is commented "the target is relative". That's clearly an invalid assumption here, and it's not surprising that:

my $save_cwd = File::Spec->catfile($cwd, $sourcedir);
_chdir($cwd);
...
_chdir($save_cwd);

gives this wrong result when $sourcedir is absolute. The easy solution is to only prepend $cwd if $sourcedir is relative:

-            my $save_cwd = File::Spec->catfile($cwd, $sourcedir);
+            my $save_cwd = File::Spec->file_name_is_absolute($sourcedir)
+			? $sourcedir
+			: File::Spec->catfile($cwd, $sourcedir);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions