Skip Menu |

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

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

People
Owner: Nobody in particular
Requestors: ambs [...] cpan.org
ANIRVAN [...] cpan.org
rjurney [...] lucision.com
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 0.30
Fixed in: (no value)



Subject: Failing tilde expansion tests
Hello. Trying to install Module::Build on my mac, used 'sudo cpan', and 'install Module::Build'. Everything got well. Just failed t/tilde errors (see bellow). I have a slight idea about why this happens (one is the root home, the other is the user doing sudo's home). t/tilde...............ok 1/17 # Failed test at t/tilde.t line 54. # got: '/var/root' # expected: '/Users/ambs' t/tilde...............NOK 3/17 # Failed test at t/tilde.t line 56. # got: '/var/root/foo' # expected: '/Users/ambs/foo' t/tilde...............ok 5/17 # Failed test at t/tilde.t line 62. # got: '/var/root/ foo' # expected: '/Users/ambs/ foo' t/tilde...............NOK 7/17 # Failed test at t/tilde.t line 64. # got: '/var/root/fo o' # expected: '/Users/ambs/fo o' t/tilde...............NOK 8/17 t/tilde...............NOK 10/17# Failed test at t/tilde.t line 68. # got: '/var/root' # expected: '/Users/ambs' # Failed test at t/tilde.t line 74. # got: '/var/root/lib' # expected: '/Users/ambs/lib' # Failed test at t/tilde.t line 76. # got: '/var/root/html' # expected: '/Users/ambs/html' # Failed test at t/tilde.t line 77. # got: '/var/root/html' # expected: '/Users/ambs/html' t/tilde...............NOK 13/17 # Failed test at t/tilde.t line 80. # got: '/var/root/lib' # expected: '/Users/ambs/lib' t/tilde...............NOK 14/17 t/tilde...............NOK 15/17# Failed test at t/tilde.t line 83. # got: '/var/root' # expected: '/Users/ambs' t/tilde...............ok 16/17# Looks like you failed 10 tests of 17. t/tilde...............dubious Test returned status 10 (wstat 2560, 0xa00) DIED. FAILED tests 3-4, 7-8, 10-15 Failed 10/17 tests, 41.18% okay
Subject: Re: [rt.cpan.org #39662] Failing tilde expansion tests
Date: Sun, 28 Sep 2008 17:54:43 -0400
To: bug-Module-Build [...] rt.cpan.org
From: Michael G Schwern <schwern [...] pobox.com>
Alberto Simões via RT wrote: Show quoted text
> Trying to install Module::Build on my mac, used 'sudo cpan', and > 'install Module::Build'.
Little tip, don't run cpan as the super user. Run it as a normal user and change make_install_make_command and mbuild_install_build_command to run "sudo make" and "sudo ./Build" respectively. That way a busted build or test stage won't be able to blow away your whole system. If you rerun the CPAN shell configuration (o conf init) it will walk you through this process. Show quoted text
> Everything got well. Just failed t/tilde errors (see bellow). > I have a slight idea about why this happens (one is the root home, the > other is the user doing sudo's home).
Unix::_detildefy() is using getpwnam $> rather than $ENV{HOME}. On my OS X 10.4, sudo sets both $> and $<. So that's a problem. Any reason it's not just using $ENV{HOME}? That's what ~ means, not what's hard coded in /etc/passwd. If $ENV{HOME} isn't defined, then fall back to getpwnam(). Try this. --- lib/Module/Build/Platform/Unix.pm (revision 67091) +++ lib/Module/Build/Platform/Unix.pm (local) @@ -47,7 +47,7 @@ $value =~ s[^~(\w[-\w]*)?(?=/|$)] # tilde with optional username [$1 ? ((getpwnam $1)[7] || "~$1") : - (getpwuid $>)[7] + ($ENV{HOME} || (getpwuid $>)[7]) ]ex; return $value; } -- Hating the web since 1994.
Yep, r11900 fixes tilde expansion with sudo.
Subject: Re: [rt.cpan.org #39662] Failing tilde expansion tests
Date: Mon, 29 Sep 2008 10:01:12 +0100
To: bug-Module-Build [...] rt.cpan.org
From: Alberto Simoes <ambs [...] cpan.org>
Michael G Schwern via RT wrote: Show quoted text
> <URL: http://rt.cpan.org/Ticket/Display.html?id=39662 > > > Alberto Simões via RT wrote:
>> Trying to install Module::Build on my mac, used 'sudo cpan', and >> 'install Module::Build'.
> > Little tip, don't run cpan as the super user. Run it as a normal user and > change make_install_make_command and mbuild_install_build_command to run "sudo > make" and "sudo ./Build" respectively. That way a busted build or test stage > won't be able to blow away your whole system. > > If you rerun the CPAN shell configuration (o conf init) it will walk you > through this process.
Thanks for the tip ;) Show quoted text
>> Everything got well. Just failed t/tilde errors (see bellow). >> I have a slight idea about why this happens (one is the root home, the >> other is the user doing sudo's home).
> > Unix::_detildefy() is using getpwnam $> rather than $ENV{HOME}. On my OS X > 10.4, sudo sets both $> and $<. So that's a problem. > > Any reason it's not just using $ENV{HOME}? That's what ~ means, not what's > hard coded in /etc/passwd. If $ENV{HOME} isn't defined, then fall back to > getpwnam(). > > Try this. > > --- lib/Module/Build/Platform/Unix.pm (revision 67091) > +++ lib/Module/Build/Platform/Unix.pm (local) > @@ -47,7 +47,7 @@ > $value =~ s[^~(\w[-\w]*)?(?=/|$)] # tilde with optional username > [$1 ? > ((getpwnam $1)[7] || "~$1") : > - (getpwuid $>)[7] > + ($ENV{HOME} || (getpwuid $>)[7]) > ]ex; > return $value; > }
Worked smoothly! 0.31 real soon now? :) -- Alberto Simões - Departamento de Informática - Universidade do Minho Campus de Gualtar - 4710-057 Braga - Portugal
CC: Schwern <schwern [...] pobox.com>
Subject: Re: [rt.cpan.org #39662] Failing tilde expansion tests
Date: Mon, 29 Sep 2008 11:05:10 -0500
To: bug-Module-Build [...] rt.cpan.org
From: "Ken Williams" <kenahoo [...] gmail.com>
On Sun, Sep 28, 2008 at 4:55 PM, Michael G Schwern via RT <bug-Module-Build@rt.cpan.org> wrote: Show quoted text
> > Any reason it's not just using $ENV{HOME}? That's what ~ means, not what's > hard coded in /etc/passwd.
I don't think that's true, from my testing with zsh: % HOME=foo echo ~ /Users/u0048513 -Ken
On Mon Sep 29 12:05:29 2008, kenahoo@gmail.com wrote: Show quoted text
> I don't think that's true, from my testing with zsh: > > % HOME=foo echo ~ > /Users/u0048513
Never mind, that was of course a flawed test. Here's a better one: % export HOME=foo % echo ~ foo -Ken
Subject: Re: [rt.cpan.org #39662] Failing tilde expansion tests
Date: Mon, 29 Sep 2008 13:45:41 -0400
To: bug-Module-Build [...] rt.cpan.org
From: Michael G Schwern <schwern [...] pobox.com>
Ken Williams via RT wrote: Show quoted text
> Queue: Module-Build > Ticket <URL: http://rt.cpan.org/Ticket/Display.html?id=39662 > > > On Mon Sep 29 12:05:29 2008, kenahoo@gmail.com wrote:
>> I don't think that's true, from my testing with zsh: >> >> % HOME=foo echo ~ >> /Users/u0048513
> > Never mind, that was of course a flawed test. Here's a better one: > > % export HOME=foo > % echo ~ > foo
Caught me out, too -- 54. "Napalm sticks to kids" is *not* a motivational phrase. -- The 213 Things Skippy Is No Longer Allowed To Do In The U.S. Army http://skippyslist.com/list/
Subject: Module::Build t/tilde.t can get confused under sudo, causing test to fail
On my CentOS 5 Linux system, when I run "sudo cpan" to install Module::Build, the t/tilde.t test fails This is because sudo transfers over my normal account's environment variables to the root account. The behavior is sometimes a good thing (e.g. I like having my $EDITOR set), but in this case, it means that my $HOME is getting passed along as well. tilde.t figures out what the user's home directory is by looking at $HOME (line 40 in Module::Build 0.30). In this case, stupidly, $HOME can't be trusted -- even though MB itself expands ~ correctly. So when I ran "sudo cpan" to install Module::Build, tilde.t saw ~myusername as the home directory (instead of ~root), and thought that all the run_sample test had failed, because they kept returning (correct) ~root dirs instead of ~anirvan dirs. I don't have a solution to this, but since Module::Build itself gets it right, I suggest either: - using whatever algorithm MB uses to determine ~ to be used in tilde.t - doing a self-test to see if $HOME and the internal "~" expansion are wrong, and spewing something useful to the user I'd be happy to help you test any potential fixes. Thanks.
Subject: Re: [rt.cpan.org #40376] Module::Build t/tilde.t can get confused under sudo, causing test to fail
Date: Sat, 25 Oct 2008 15:52:58 -0700
To: bug-Module-Build [...] rt.cpan.org
From: Michael G Schwern <schwern [...] pobox.com>
Anirvan Chatterjee via RT wrote: Show quoted text
> This is because sudo transfers over my normal account's environment > variables to the root account. The behavior is sometimes a good thing > (e.g. I like having my $EDITOR set), but in this case, it means that my > $HOME is getting passed along as well.
What do these do? sudo echo ~ sudo echo $HOME
Subject: Re: [rt.cpan.org #40376] Module::Build t/tilde.t can get confused under sudo, causing test to fail
Date: Sat, 25 Oct 2008 19:03:37 -0700
To: Michael G Schwern via RT <bug-Module-Build [...] rt.cpan.org>
From: Anirvan Chatterjee <ANIRVAN [...] cpan.org>
On Sat, Oct 25, 2008 at 06:54:00PM -0400, Michael G Schwern via RT wrote: Show quoted text
> What do these do?
I ran these, and some other tests, trying to see if I could turn up anything interesting. The only vaguely interesting thing I found is at the end of this email -- the $USER and $SUDO* environment variables. Thanks again for looking into this. % sudo echo ~ /home/my-username % sudo echo $HOME /home/my-username % sudo whoami root % sudo perl -e 'print "$ENV{HOME}\n"' /home/my-username % sudo su # echo ~ /root # echo $HOME /root % su # echo ~ /root # echo $HOME /root % su -c 'echo ~' /root % su -c 'echo $HOME' /root % sudo env # uninteresting lines snipped MAIL=/var/spool/mail/my-username HOME=/home/my-username LOGNAME=root USER=root SUDO_COMMAND=/bin/env SUDO_USER=my-username SUDO_UID=500 # my account's user ID SUDO_GID=500 # my account's group ID -- Anirvan Chatterjee www.chatterjee.net www.bookfinder.com
Subject: Re: [rt.cpan.org #40376] Module::Build t/tilde.t can get confused under sudo, causing test to fail
Date: Sun, 26 Oct 2008 09:21:49 -0700
To: bug-Module-Build [...] rt.cpan.org
From: Eric Wilhelm <scratchcomputing [...] gmail.com>
# from Anirvan Chatterjee via RT on Saturday 25 October 2008: Show quoted text
>% sudo echo ~ >/home/my-username > >% sudo echo $HOME >/home/my-username >... >% su -c 'echo ~' >/root >% su -c 'echo $HOME' >/root
Note that the first two don't say anything about su. The tilde and variable are expanded by the user's shell before being passed to su. --Eric
Subject: Module tests fail when installing with 'sudo'
Date: Tue, 28 Oct 2008 21:55:12 -0400
To: bug-Module-Build [...] rt.cpan.org
From: Russell Jurney <rjurney [...] lucision.com>
rjurney@ubuntu:/mnt/osx/al_trunk/iet$ sudo cpan Module::Build CPAN: Storable loaded ok (v2.15) Going to read /home/rjurney/.cpan/Metadata Database was generated on Tue, 28 Oct 2008 11:26:55 GMT CPAN: YAML loaded ok (v0.66) Going to read 17 yaml files from /home/rjurney/.cpan/build/ CPAN: Time::HiRes loaded ok (v1.86) ............................................................................DONE Restored the state of 17 (in 0.6760 secs) Running install for module 'Module::Build' Running make for K/KW/KWILLIAMS/Module-Build-0.30.tar.gz Has already been unwrapped into directory /home/rjurney/.cpan/build/ Module-Build-0.30-h72tBo Has already been made Running make test /usr/bin/perl Build --makefile_env_macros 1 test t/basic...............ok t/compat..............ok t/destinations........ok t/ext.................ok t/extend..............ok t/files...............ok t/help................ok t/install.............ok t/manifypods..........ok t/mbyaml..............ok t/metadata............ok t/metadata2...........ok t/moduleinfo..........ok t/new_from_context....ok t/notes...............ok t/par.................ok t/parents.............ok t/pod_parser..........ok t/ppm.................ok t/runthrough..........ok t/script_dist.........ok t/signature...........skipped: $ENV{TEST_SIGNATURE} is not set t/test_file_exts......ok t/test_type...........ok t/test_types..........ok t/tilde...............1/17 # Failed test at t/tilde.t line 54. # got: '/root' # expected: '/home/rjurney' t/tilde...............4/17 # Failed test at t/tilde.t line 56. # got: '/root/foo' # expected: '/home/rjurney/foo' # Failed test at t/tilde.t line 62. # got: '/root/ foo' # expected: '/home/rjurney/ foo' # Failed test at t/tilde.t line 64. # got: '/root/fo o' # expected: '/home/rjurney/fo o' # Failed test at t/tilde.t line 68. # got: '/root' # expected: '/home/rjurney' # Failed test at t/tilde.t line 74. # got: '/root/lib' # expected: '/home/rjurney/lib' # Failed test at t/tilde.t line 76. # got: '/root/html' # expected: '/home/rjurney/html' # Failed test at t/tilde.t line 77. # got: '/root/html' # expected: '/home/rjurney/html' # Failed test at t/tilde.t line 80. # got: '/root/lib' # expected: '/home/rjurney/lib' # Failed test at t/tilde.t line 83. # got: '/root' # expected: '/home/rjurney' # Looks like you failed 10 tests of 17. t/tilde............... Dubious, test returned 10 (wstat 2560, 0xa00) Failed 10/17 subtests t/use_tap_harness.....ok t/versions............ok t/xs..................ok Test Summary Report ------------------- t/tilde (Wstat: 2560 Tests: 17 Failed: 10) Failed tests: 3-4, 7-8, 10-15 Non-zero exit status: 10 Files=29, Tests=999, 45 wallclock secs ( 0.21 usr 0.58 sys + 25.65 cusr 18.62 csys = 45.06 CPU) Result: FAIL Failed 1/29 test programs. 10/999 subtests failed. make: *** [test] Error 255 KWILLIAMS/Module-Build-0.30.tar.gz /usr/bin/make test -- NOT OK //hint// to see the cpan-testers results for installing this module, try: reports KWILLIAMS/Module-Build-0.30.tar.gz Running make install make test had returned bad status, won't install without force Stopping: 'install' failed for 'Module::Build'.