Skip Menu |

This queue is for tickets about the Module-Build CPAN distribution.

Report information
The Basics
Id: 57043
Status: resolved
Priority: 0/
Queue: Module-Build

People
Owner: Nobody in particular
Requestors: dekimsey [...] at.ufl.edu
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: 0.36_08
Fixed in: (no value)



Subject: modulebuildrc overrides parameters given on the command-line
It would seem that any attempt at providing the install_base command- line option gets ignored. I believe that if a command-line parameter is provided it should override the configured rc setting. For the following examples I'm assuming .modulebuildrc reads as such: install --install_path /tmp/doom Example 1 works as would be expected, specifying no install_base on the command_line makes M::B use the rc configured path. $ perl Build.PL # $self->install_base is undefined $ ./Build # $self->install_base is undefined $ ./Build install # installed to modulebuildrc's specified location. Example 2 specifying install_base during install does not override the rc configured path. $ perl Build.PL # $self->install_base is undefined $ ./Build # $self->install_base is undefined $ ./Build install --install_base=$HOME/foobar # installed to modulebuildrc's specified location?? why not $HOME/foobar? Example 3 specifying install_base during Build_PL does not override the rc configured path. $ perl Build.PL --install_base=$HOME/foobar # $self->install_base = $HOME/foobar $ ./Build # $self->install_base = $HOME/foobar $ ./Build install --install_base=$HOME/foobar # installed to modulebuildrc's specified location?? why not $HOME/foobar? This last example I'm demonstrating for completeness, frankly if this doesn't happen, I know I can live with it. Example 4 specifying install_base during build does not override the rc configured path. $ perl Build.PL # $self->install_base is undefined $ ./Build --install_base=$HOME/foobar # $self->install_base = $HOME/foobar $ ./Build install --install_base=$HOME/foobar # installed to modulebuildrc's specified location?? why not $HOME/foobar?
From: dekimsey [...] at.ufl.edu
Attached is a test file to demonstrate this.
Subject: t-57043-install_base_precedence.t
# sample.t -- a sample test file for Module::Build use strict; use lib 't/lib'; use MBTest; use DistGen; plan tests => 21; # Ensure any Module::Build modules are loaded from correct directory blib_load('Module::Build'); # create dist object in a temp directory # enter the directory and generate the skeleton files my $dist = DistGen->new->chdir_in->regen; sub update_mbrc { my $temp_install_rc = shift; # Add a modulebuildrc file to the HOME. my $mbrc_file = $ENV{HOME} . "/.modulebuildrc"; my $fh = IO::File->new($mbrc_file, '>') or die "Can't create $mbrc_file: $!"; print $fh "install --install_base $temp_install_rc\n"; $fh->close; ok -e $mbrc_file; return $temp_install_rc; } # Example 1: Specifying no install_base on the command_line makes M::B use the rc configured path. { my $temp_install_rc = update_mbrc(MBTest::tmpdir()); my $mb = $dist->new_from_context(); # quiet by default isa_ok( $mb, "Module::Build" ); is( $mb->dist_name, "Simple", "dist_name is 'Simple'" ); is( $mb->install_base, undef, "install_base setting is not yet-defined ok" ); my $out = stdout_stderr_of( sub { $dist->run_build('install'); }); like( $out, qr{Installing $temp_install_rc/lib/perl5/Simple.pm}, "Used modulebuildrc install_base ok" ); } #Example 2: specifying install_base during install overrides the rc configured path. { my $temp_install = MBTest::tmpdir(); my $temp_install_rc = update_mbrc(MBTest::tmpdir()); my $mb = $dist->new_from_context(); # quiet by default isa_ok( $mb, "Module::Build" ); is( $mb->dist_name, "Simple", "dist_name is 'Simple'" ); is( $mb->install_base, undef, "install_base setting is not yet-defined ok" ); my $out = stdout_stderr_of( sub { $dist->run_build('install', install_base => $temp_install); }); like( $out, qr{Installing $temp_install/lib/perl5/Simple.pm}, "Used cmd-line install_base (defined during install) ok" ); } #Example 3: specifying install_base during Build_PL should override the rc configured path. { my $temp_install = MBTest::tmpdir(); my $temp_install_rc = update_mbrc(MBTest::tmpdir()); my $mb = $dist->new_from_context( install_base => $temp_install, ); # quiet by default isa_ok( $mb, "Module::Build" ); is( $mb->dist_name, "Simple", "dist_name is 'Simple'" ); is( $mb->install_base, $temp_install, "install_base setting matches cmd-line (defined during Build_PL) ok" ); my $out = stdout_stderr_of( sub { $dist->run_build('install'); }); like( $out, qr{Installing $temp_install/lib/perl5/Simple.pm}, "Used cmd-line install_base (defined during Build_PL) ok" ); } #Example 4: specifying install_base during build should override the rc configured path. { my $temp_install = MBTest::tmpdir(); my $temp_install_rc = update_mbrc(MBTest::tmpdir()); my $mb = $dist->new_from_context(); # quiet by default isa_ok( $mb, "Module::Build" ); is( $mb->dist_name, "Simple", "dist_name is 'Simple'" ); is( $mb->install_base, undef, "install_base setting is not yet-defined ok" ); $dist->run_build('build', install_base => $temp_install); is( $mb->install_base, $temp_install, "install_base setting is set (during Build) ok" ); my $out = stdout_stderr_of( sub { $dist->run_build('install'); }); like( $out, qr{Installing $temp_install/lib/perl5/Simple.pm}, "Used cmd-line install_base (defined during build) ok" ); } # vim:ts=2:sw=2:et:sta:sts=2
Subject: Re: [rt.cpan.org #57043] modulebuildrc overrides parameters given on the command-line
Date: Thu, 29 Apr 2010 09:15:52 -0700
To: bug-Module-Build [...] rt.cpan.org
From: Michael G Schwern <schwern [...] pobox.com>
On 2010.4.29 8:48 AM, http://dekimsey.myopenid.com/ via RT wrote: Show quoted text
> It would seem that any attempt at providing the install_base command- > line option gets ignored. I believe that if a command-line parameter is > provided it should override the configured rc setting.
I can replicate this problem with the latest version from github. I believe what's happening is Module::Build applies the modulebuildrc defaults per action and not per key. Therefore if you specify --install_base at Build.PL time it is considered a different argument than --install_base to ./Build install. It says "oh, install didn't get an install_base argument so I'll use the default". This is confusing. My guess is you've set "install --install_base /foo/bar" in modulebuildrc. In this case it will always override whatever you set at Build.PL time. A work around is to use the Build_PL psuedo-target instead. "Build_PL --install_base /foo/bar". Its probably best to set it as early as possible anyway as it may be used during the build process, so I'll change the example. If you're intending to repackage the module, use destdir instead. -- I have a date with some giant cartoon robots and booze.
Subject: Re: [rt.cpan.org #57043] modulebuildrc overrides parameters given on the command-line
Date: Thu, 29 Apr 2010 09:24:52 -0700
To: bug-Module-Build [...] rt.cpan.org
From: Michael G Schwern <schwern [...] pobox.com>
On 2010.4.29 9:16 AM, Michael G Schwern via RT wrote: Show quoted text
> My guess is you've set "install --install_base /foo/bar" in modulebuildrc. > In this case it will always override whatever you set at Build.PL time. A > work around is to use the Build_PL psuedo-target instead. "Build_PL > --install_base /foo/bar". > > Its probably best to set it as early as possible anyway as it may be used > during the build process, so I'll change the example. If you're intending to > repackage the module, use destdir instead.
David, you can pull that doc change from. http://github.com/schwern/module-build Github seems to have the sniffles. -- Robrt: People can't win Schwern: No, but they can riot after the game.
From: dekimsey [...] at.ufl.edu
On Thu Apr 29 12:16:05 2010, schwern@pobox.com wrote: Show quoted text
> On 2010.4.29 8:48 AM, http://dekimsey.myopenid.com/ via RT wrote: > I believe what's happening is Module::Build applies the modulebuildrc > defaults > per action and not per key. Therefore if you specify --install_base > at > Build.PL time it is considered a different argument than > --install_base to > ./Build install. It says "oh, install didn't get an install_base > argument so > I'll use the default". This is confusing.
The problem is that even if I were to specify the install_base on the command-line during the install action, modulebuildrc's (install specific) action continues to override. I don't think this should be the case. On Thu Apr 29 12:16:05 2010, schwern@pobox.com wrote: Show quoted text
> My guess is you've set "install --install_base /foo/bar" in > modulebuildrc. > In this case it will always override whatever you set at Build.PL > time.
This appears to be the default behavior of cpanm. Probably suggest that get changed to the pseudo target as suggested. However, it doesn't
My apologies on the double-post, I would kill for the ability to edit replies... On Thu Apr 29 12:16:05 2010, schwern@pobox.com wrote: Show quoted text
> I believe what's happening is Module::Build applies the modulebuildrc > defaults per action and not per key. Therefore if you specify --install_base at Build.PL time it is
considered a different argument than Show quoted text
> --install_base to ./Build install. It says "oh, install didn't get an install_base > argument so I'll use the default". This is confusing.
The problem is that even if I were to specify the install_base on the command-line during the install action, modulebuildrc's (install specific) action continues to override. I don't think this should be the case. On Thu Apr 29 12:16:05 2010, schwern@pobox.com wrote: Show quoted text
> My guess is you've set "install --install_base /foo/bar" in > modulebuildrc. > In this case it will always override whatever you set at Build.PL > time.
This appears to be the default behavior of cpanm. Probably suggest that get changed to the pseudo target as suggested. Even if it were to use the Build_PL action, the prior issue still remains.
On Thu Apr 29 13:36:49 2010, http://dekimsey.myopenid.com/ wrote: Show quoted text
> This appears to be the default behavior of cpanm. Probably suggest > that get changed to the pseudo target as suggested. Even if > it were to use the Build_PL action, the prior issue still remains.
Incorrect on the cpanm statement. Defining the modulebuildrc file to use "install --install_base /foo" is the behavior of local::lib. I've submitted a bug report for local::lib to change its defaults to not be as specific. See: https://rt.cpan.org/Public/Bug/Display.html?id=57049
Subject: Re: [rt.cpan.org #57043] modulebuildrc overrides parameters given on the command-line
Date: Thu, 29 Apr 2010 14:34:17 -0400
To: bug-Module-Build [...] rt.cpan.org
From: David Golden <dagolden [...] cpan.org>
It sure sounds like a bug, but partly because the behavior is not well defined. Here is an attempt to define proper precedence rules. During execution of Build.PL or Build, options should have the following precedence (from high to low): * @ARGV * $ENV{PERL_MB_OPT} * configuration file -- action-specific options * cached configuration from Build.PL (only when running Build) * configuration file -- wildcard (*) Conceptually, options should be split on white space and then spliced together, with higher-precedence options following lower-precedence options. Options should then be processed "in order". Any objections or criticisms? -- David
Close as invalid. I've looked at the issue further, and it would appear that my test was wrong. I mistakenly thought the arguments provided for run_build(...) followed the same format as those during new_from_context. Specifically it should have read run_build( --install_base => '/foo/bar' ) and not run_build(install_base => '/foo/bar'). Making these fixes appears to deal with the incorrectly reported issue. As to whether a command-line given (say during Build_PL) parameter should override a more specific modulebuildrc parameter (say during install) is up for the developers to decide. I suspect it will not be the case. Please close this bug.
Subject: t-57043-install_base_precedence.t
# sample.t -- a sample test file for Module::Build use strict; use lib 't/lib'; use MBTest; use DistGen; plan tests => 20; # Ensure any Module::Build modules are loaded from correct directory blib_load('Module::Build'); # create dist object in a temp directory # enter the directory and generate the skeleton files my $dist = DistGen->new->chdir_in->regen; sub update_mbrc { my $temp_install_rc = shift; my $action = shift || 'install'; # Add a modulebuildrc file to the HOME. my $mbrc_file = $ENV{HOME} . "/.modulebuildrc"; my $fh = IO::File->new($mbrc_file, '>') or die "Can't create $mbrc_file: $!"; print $fh "$action --install_base $temp_install_rc\n"; $fh->close; ok -e $mbrc_file; return $temp_install_rc; } # Example 1: Specifying no install_base on the command_line makes M::B use the rc configured path. { my $temp_install_rc = update_mbrc(MBTest::tmpdir()); my $mb = $dist->new_from_context(); # quiet by default isa_ok( $mb, "Module::Build" ); is( $mb->dist_name, "Simple", "dist_name is 'Simple'" ); is( $mb->install_base, undef, "install_base setting is not yet-defined ok" ); my $out = stdout_stderr_of( sub { $dist->run_build('install'); }); like( $out, qr{Installing $temp_install_rc/lib/perl5/Simple.pm}, "Used modulebuildrc install_base ok" ); } #Example 2: specifying install_base during install should override the # equally specific rc configured path. { my $temp_install = MBTest::tmpdir(); my $temp_install_rc = update_mbrc(MBTest::tmpdir()); my $mb = $dist->new_from_context(); # quiet by default isa_ok( $mb, "Module::Build" ); is( $mb->dist_name, "Simple", "dist_name is 'Simple'" ); is( $mb->install_base, undef, "install_base setting is not yet-defined ok" ); my $out = stdout_stderr_of( sub { $dist->run_build('install', '--install_base' => $temp_install); }); like( $out, qr{Installing $temp_install/lib/perl5/Simple.pm}, "Used cmd-line install_base (defined during install) ok" ); } #Example 3: specifying install_base during Build_PL shouldn't override the more specific # rc configured path. { my $temp_install = MBTest::tmpdir(); my $temp_install_rc = update_mbrc(MBTest::tmpdir()); my $mb = $dist->new_from_context( 'install_base' => $temp_install, ); # quiet by default isa_ok( $mb, "Module::Build" ); is( $mb->dist_name, "Simple", "dist_name is 'Simple'" ); is( $mb->install_base, $temp_install, "install_base setting matches cmd-line (defined during Build_PL) ok" ); my $out = stdout_stderr_of( sub { $dist->run_build('install'); }); like( $out, qr{Installing $temp_install_rc/lib/perl5/Simple.pm}, "Used rc install_base over cmd-line Build_PL's install_base ok" ); } #Example 5: specifying install_base during install should override # the less-specific rc configured path. { my $temp_install = MBTest::tmpdir(); my $temp_install_rc = update_mbrc(MBTest::tmpdir(), 'Build_PL'); my $mb = $dist->new_from_context(); # quiet by default isa_ok( $mb, "Module::Build" ); is( $mb->dist_name, "Simple", "dist_name is 'Simple'" ); is( $mb->install_base, $temp_install_rc, "install_base setting is defined ok" ); $dist->run_build('build'); my $out = stdout_stderr_of( sub { $dist->run_build('install', '--install_base' => $temp_install); }); like( $out, qr{Installing $temp_install/lib/perl5/Simple.pm}, "Used cmd-line install_base (overridden during install) ok" ); } # vim:ts=2:sw=2:et:sta:sts=2