This queue is for tickets about the CPAN CPAN distribution.

Report information
The Basics
Id:
76831
Status:
resolved
Priority:
Low/Low
Queue:

People
Owner:
Nobody in particular
Requestors:
RURBAN [...] cpan.org
Cc:
AdminCc:

BugTracker
Severity:
Critical
Broken in:
2.02-TRIAL
Fixed in:
2.05



Subject: make install fails with spaces in make_install_make_command
Default ActiveState/MSVC9 build, with make_install_make_command being stored as q[C:\Program Files\Microsoft Visual Studio 9.0\VC\BIN\nmake.EXE] make test correctly quotes the system call, make install not. Error: "C:\Program Files\Microsoft Visual Studio 9.0\VC\BIN\nmake.EXE" test - - OK Running make install 'C:\Program' is not recognized as an internal or external command, operable program or batch file. This looks right to me: diff --git a/cpan/CPAN/lib/CPAN/Distribution.pm b/cpan/CPAN/lib/CPAN/Distribution.pm index 32648ec..18a11da 100644 --- a/cpan/CPAN/lib/CPAN/Distribution.pm +++ b/cpan/CPAN/lib/CPAN/Distribution.pm @@ -3555,7 +3555,9 @@ sub install { $CPAN::Config->{mbuild_install_build_command} : $self->_build_command(); $system = sprintf("%s install %s", - $mbuild_install_build_command, + $mbuild_install_build_command =~ m/\s/ + ? qq{"$mbuild_install_build_command"} + : $mbuild_install_build_command, $CPAN::Config->{mbuild_install_arg}, ); } else { @@ -3564,7 +3566,9 @@ sub install { q{make_install_make_command}) || $self->_make_command(); $system = sprintf("%s install %s", - $make_install_make_command, + $make_install_make_command =~ m/\s/ + ? qq{"$make_install_make_command"} + : $make_install_make_command, $CPAN::Config->{make_install_arg}, ); } -- Reini Urban
Nope. This approach will fail with 'sudo make' Better store the command already quoted correctly and fix the quoting in sub test. On Thu Apr 26 16:15:03 2012, RURBAN wrote:
Show quoted text
> Default ActiveState/MSVC9 build, with > make_install_make_command being stored as > q[C:\Program Files\Microsoft Visual Studio 9.0\VC\BIN\nmake.EXE] > > make test correctly quotes the system call, make install not. > Error: > "C:\Program Files\Microsoft Visual Studio 9.0\VC\BIN\nmake.EXE" test
-
Show quoted text
> - OK > Running make install > 'C:\Program' is not recognized as an internal or external command, > operable program or batch file. > > This looks right to me: > > diff --git a/cpan/CPAN/lib/CPAN/Distribution.pm > b/cpan/CPAN/lib/CPAN/Distribution.pm > index 32648ec..18a11da 100644 > --- a/cpan/CPAN/lib/CPAN/Distribution.pm > +++ b/cpan/CPAN/lib/CPAN/Distribution.pm > @@ -3555,7 +3555,9 @@ sub install { > $CPAN::Config->{mbuild_install_build_command} : > $self->_build_command(); > $system = sprintf("%s install %s", > - $mbuild_install_build_command, > + $mbuild_install_build_command =~ m/\s/ > + ? qq{"$mbuild_install_build_command"} > + : $mbuild_install_build_command, > $CPAN::Config->{mbuild_install_arg}, > ); > } else { > @@ -3564,7 +3566,9 @@ sub install { > > q{make_install_make_command}) > || $self->_make_command(); > $system = sprintf("%s install %s", > - $make_install_make_command, > + $make_install_make_command =~ m/\s/ > + ? qq{"$make_install_make_command"} > + : $make_install_make_command, > $CPAN::Config->{make_install_arg}, > ); > } >
-- Reini Urban
Show quoted text
> Better store the command already quoted correctly > and fix the quoting in sub test.
What do you think needs fixing in sub test? *_install_make_command is only used for installing, not for testing.
CC: RURBAN@cpan.org
Subject: Re: [rt.cpan.org #76831] make install fails with spaces in make_install_make_command
Date: Tue, 1 May 2012 12:25:28 -0500
To: bug-CPAN@rt.cpan.org
From: Reini Urban <rurban@x-ray.at>
On Mon, Apr 30, 2012 at 10:56 PM, Andreas Koenig via RT <bug-CPAN@rt.cpan.org> wrote:
Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=76831 > >
>> Better store the command already quoted correctly >> and fix the quoting in sub test.
> > What do you think needs fixing in sub test? *_install_make_command is > only used for installing, not for testing.
For the common MSVC nmake case we have two CPAN Config make settings with spaces in the path. 'make' => q[c:\\Program Files\\Microsoft Visual Studio 9.0\\VC\\BIN\\nmake.EXE], 'make_install_make_command' => q[c:\\Program Files\\Microsoft Visual Studio 9.0\\VC\\BIN\\nmake.EXE], make test works fine (using the first), make install (using the second) not. The quoting rules are different for the two commands. Easy to explain why. 'make' is only a program, it cannot be a program with args. cpan quotes it. make_install_make_command can be 'sudo make', so it is mostly a program with args, so it cannot quoted as whole. The only sane solution to fix this is to quote spaces in both hash entries, and do not bother with it in the commands. -- Reini Urban http://cpanel.net/   http://www.perl-compiler.org/
Subject: [PATCH] make install fails with spaces in make_install_make_command
The attached patch against 2.02-TRIAL gives a pragmatic solution: quote the make_install_make_command just like make_command is quoted, but only on Windows. The problem of spaces in the path arises most commonly on Windows, and whilst there are versions of "sudo" around for Windows I've never encountered it myself so I'm guessing it's extremely unusual. I agree that quoting the program paths in the stored hash is a fuller/better solution but there are many other program paths in the same hash, so arguably they should all be quoted if necessary too. I don't have the time or know enough about CPAN.pm to go down that road so I favour this simpler approach instead, which I believe will solve the vast majority of cases. Please can we have a new release in the near future with this problem fixed? It has bugged me for ages!
Subject: install.patch
diff -ruN CPAN-2.02-TRIAL.orig/lib/CPAN/Distribution.pm CPAN-2.02-TRIAL/lib/CPAN/Distribution.pm --- CPAN-2.02-TRIAL.orig/lib/CPAN/Distribution.pm 2013-06-23 07:18:08.000000000 +0100 +++ CPAN-2.02-TRIAL/lib/CPAN/Distribution.pm 2013-09-11 09:04:22.874356400 +0100 @@ -2554,6 +2554,21 @@ } } +sub _make_install_make_command { + my ($self) = @_; + my $mimc = + CPAN::HandleConfig->prefs_lookup($self, q{make_install_make_command}); + return $self->_make_command() unless $mimc; + + # Quote the "make install" make command on Windows, where it is commonly + # found in, e.g., C:\Program Files\... and therefore needs quoting. We can't + # do this in general because the command maybe "sudo make..." (i.e. a + # program with arguments), but that is unlikely to be the case on Windows. + $mimc = CPAN::HandleConfig->safe_quote($mimc) if $^O eq 'MSWin32'; + + return $mimc; +} + #-> sub CPAN::Distribution::follow_prereqs ; sub follow_prereqs { my($self) = shift; @@ -3706,10 +3721,7 @@ ); } else { - my($make_install_make_command) = - CPAN::HandleConfig->prefs_lookup($self, - q{make_install_make_command}) - || $self->_make_command(); + my($make_install_make_command) = $self->_make_install_make_command(); $system = sprintf("%s install %s", $make_install_make_command, $CPAN::Config->{make_install_arg},
Thanks Reini, Steve. Resolving finally now.


This service runs on Request Tracker, is sponsored by The Perl Foundation, and maintained by Best Practical Solutions.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.