miyagawa / cpanminus

cpanminus - get, unpack, build and install modules from CPAN
http://cpanmin.us
754 stars 213 forks source link

Will pick cygwin's tar, causing permissions problems #464

Open haarg opened 9 years ago

haarg commented 9 years ago

If you have a Win32 system that includes cygwin in its PATH, cpanm will find cygwin's tar.exe and use it for extracting tarballs. The filesystem semantics it uses don't match how Windows handles them, leading to things like prompting for every file if you try to delete the build files through the GUI.

It might make sense to avoid using Cygwin tools unless $^O eq 'cygwin'.

Example cpanm -v output:

C:\Users\Mithaldu>cpanm -v
cpanm (App::cpanminus) 1.7004 on perl 5.016003 built for MSWin32-x86-multi-thread
Work directory is C:\Users\Mithaldu/.cpanm/work/1434488587.37360
You have make c:\Perl\site\bin\dmake.exe
You have LWP 6.13
You have C:\cygwin\bin\tar.exe, C:\cygwin\bin\gzip.exe and C:\cygwin\bin\bzip2.exe
You have C:\cygwin\bin\unzip.exe
Usage: cpanm [options] Module [...]

Try `cpanm --help` or `man cpanm` for more options.

Example tar --version output from cygwin:

$ tar --version
tar (GNU tar) 1.28
Packaged by Cygwin (1.28-1)
Copyright (C) 2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by John Gilmore and Jay Fenlason.
wchristian commented 9 years ago

Maybe relying on this is a good idea:

C:\Windows\System32>corelist Archive::Tar

Data for 2015-02-14
Archive::Tar was first released with perl v5.9.3
miyagawa commented 9 years ago

Does this work for you?

diff --git a/lib/App/cpanminus/script.pm b/lib/App/cpanminus/script.pm
index 997092a..d48c185 100644
--- a/lib/App/cpanminus/script.pm
+++ b/lib/App/cpanminus/script.pm
@@ -16,7 +16,7 @@ use String::ShellQuote ();
 use version ();

 use constant WIN32 => $^O eq 'MSWin32';
-use constant BAD_TAR => ($^O eq 'solaris' || $^O eq 'hpux');
+use constant BAD_TAR => (WIN32 || $^O eq 'solaris' || $^O eq 'hpux');
 use constant CAN_SYMLINK => eval { symlink("", ""); 1 };

 our $VERSION = $App::cpanminus::VERSION;
miyagawa commented 9 years ago

Hm, nevermind it already does WIN32 check in maybe_bad_tar. There's some missing combination that it cannot detect when there is gzip/bzip.

wchristian commented 9 years ago

Does C:\Perl\site\lib\App\cpanminus.pm: 1.7004 have that code already? Maybe my cpanm is too old.

miyagawa commented 9 years ago

Yes, 1.7004 has that already. But it only uses it to check if tar has supported uncompression options. But nevertheless upgrading is always recommended.

miyagawa commented 9 years ago

The options are:

I think flipping the order is the simplest.

haarg commented 9 years ago

Another option is to run tar --version and reject it if it is the Cygwin version and not running under Cygwin. cpanm already does something along these lines for other tar versions.

I'm not yet advocating for a specific solution to this though. Still need to give it more thought.