Bug 13575

Summary: perl Makefile.PL LIB=~/lib;make install fails
Product: Base System Reporter: drxyzzy <drxyzzy>
Component: miscAssignee: freebsd-bugs (Nobody) <bugs>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: 3.2-RELEASE   
Hardware: Any   
OS: Any   

Description drxyzzy 1999-09-04 19:20:01 UTC
It should be possible to install a standard Perl module without
root privileges. This is documented in the Perl Cookbook and works
as advertised in OpenBSD-2.5 (recent snap) which also bundles Perl
5.005_03, but it fails with FreeBSD.

How-To-Repeat: 
Login as non superuser.
mkdir ~/lib
tar -xvzf Storable-0.6@4.tar.gz
cd Storable-0.6@4
# LIB value should allow non-root install to local dir
perl Makefile.PL LIB=~/lib
make
make test
make install

"make test" succeeds. "make install" fails with the following error:

mkdir /usr/local/lib/perl5/5.00503: Permission denied at /usr/libdata/perl/5.00503/ExtUtils/Install.pm line 57
*** Error code 2
Comment 1 chris freebsd_committer freebsd_triage 1999-09-04 19:38:37 UTC
State Changed
From-To: open->closed

This is not a FreeBSD problem. 

Comment 2 chris 1999-09-04 19:40:47 UTC
On Sat, Sep 04, 1999, drxyzzy@mediaone.net wrote:
> Login as non superuser.
> mkdir ~/lib
> tar -xvzf Storable-0.6@4.tar.gz
> cd Storable-0.6@4
> # LIB value should allow non-root install to local dir
> perl Makefile.PL LIB=~/lib

   Place `LIB' at the _beginning_ of the line.

   In any case, this is a problem with `Makefile.PL' in your
module, not FreeBSD.

-- 
|Chris Costello <chris@calldei.com>
|The next generation of computers will have a "Warranty Expired" interrupt.
`--------------------------------------------------------------------------
Comment 3 drxyzzy 1999-09-04 19:58:21 UTC
Chris Costello <chris@calldei.com> writes:

> On Sat, Sep 04, 1999, drxyzzy@mediaone.net wrote:
> > Login as non superuser.
> > mkdir ~/lib
> > tar -xvzf Storable-0.6@4.tar.gz
> > cd Storable-0.6@4
> > # LIB value should allow non-root install to local dir
> > perl Makefile.PL LIB=~/lib
> 
>    Place `LIB' at the _beginning_ of the line.

Same thing happens with LIB at beginning of line.

I suspect FreeBSD cruft relating to moving perl5 from /usr/local to
/usr/libdata since the error arises from FreeBSD perl Wanting to
scribble in /usr/local.

>    In any case, this is a problem with `Makefile.PL' in your
> module, not FreeBSD.

It's not my module, it's a commonly used module from CPAN.

The problem does not happen with same version of Perl, same module
(same Makefile.PL) when running on OpenBSD. This suggests, but does
not prove, that it is a problem with the perl binary or supporting
libs shipped with FreeBSD.
Comment 4 drxyzzy 1999-09-04 20:16:08 UTC
Chris Costello <chris@calldei.com> writes:

> On Sat, Sep 04, 1999, drxyzzy@mediaone.net wrote:
> > Login as non superuser.
> > mkdir ~/lib
> > tar -xvzf Storable-0.6@4.tar.gz
> > cd Storable-0.6@4
> > # LIB value should allow non-root install to local dir
> > perl Makefile.PL LIB=~/lib
> 
>    Place `LIB' at the _beginning_ of the line.

man ExtUtils::MakeMaker 

perl Makefile.PL NAME=VALUE... is supported for setting Makefile
Attributes and Paramters.
Comment 5 Bill Fenner freebsd_committer freebsd_triage 1999-09-05 01:05:44 UTC
State Changed
From-To: closed->open

This is a real problem, and is definitely related to how perl is installed 
on FreeBSD.  It may be a bug in ExtUtils::MM_Unix.pm, but it is still 
something that we need to look into. 

Comment 6 Bill Fenner 1999-09-05 02:12:53 UTC
I created the following Makefile.PL:

use ExtUtils::MakeMaker;
WriteMakefile( NAME => "Foo::Bar" );

and created a Bar.pm with a little bit of pod, and ran "perl Makefile.PL
LIB=/tmp" to create a Makefile.

I found some interesting things:

- Perl on 3.2-STABLE creates Makefiles with "OSVERS = 4.0-current"
  and ccsymbols including __FreeBSD__=4 and __FreeBSD_cc_version=400002.
- The machine-specific identifier in path names is sometimes "mach" and
  sometimes "i386-freebsd", where on other systems it is consistent.

And, in fact, I think I found the bug.  My hypothesis is that the
difference between the two machines is not that one is OpenBSD and
one is FreeBSD; rather, the one on which installation works already
has some perl modules installed in /usr/local/lib/perl5 and the one
on which it doesn't doesn't.  When I did a "make install", everything
worked fine until I moved /usr/local/lib/perl5 out of the way.

fenestro# mv perl5 perl5.not
fenestro# suspend

Suspended
fenestro% make install
mkdir /usr/local/lib/perl5: Permission denied at /usr/libdata/perl/5.00503/ExtUtils/Install.pm line 57
*** Error code 2
su
fenestro# mv perl5.not perl5
fenestro# suspend

Suspended
fenestro% make install
Warning: You do not have permissions to install into /usr/local/lib/perl5/5.00503/man/man3 at /usr/libdata/perl/5.00503/ExtUtils/Install.pm line 61.
Skipping /tmp/i386-freebsd/auto/Storable/Storable.so (unchanged)
Skipping /tmp/i386-freebsd/auto/Storable/Storable.bs (unchanged)
Files found in blib/arch --> Installing files in blib/lib into architecture dependend library tree!
Skipping /tmp/i386-freebsd/auto/Storable/store.al (unchanged)
Skipping /tmp/i386-freebsd/auto/Storable/nstore.al (unchanged)
Skipping /tmp/i386-freebsd/auto/Storable/_store.al (unchanged)
Skipping /tmp/i386-freebsd/auto/Storable/store_fd.al (unchanged)
Skipping /tmp/i386-freebsd/auto/Storable/nstore_fd.al (unchanged)
Skipping /tmp/i386-freebsd/auto/Storable/_store_fd.al (unchanged)
Skipping /tmp/i386-freebsd/auto/Storable/freeze.al (unchanged)
Skipping /tmp/i386-freebsd/auto/Storable/nfreeze.al (unchanged)
Skipping /tmp/i386-freebsd/auto/Storable/_freeze.al (unchanged)
Skipping /tmp/i386-freebsd/auto/Storable/retrieve.al (unchanged)
Skipping /tmp/i386-freebsd/auto/Storable/retrieve_fd.al (unchanged)
Skipping /tmp/i386-freebsd/auto/Storable/thaw.al (unchanged)
Skipping /tmp/i386-freebsd/auto/Storable/autosplit.ix (unchanged)
Skipping /tmp/i386-freebsd/Storable.pm (unchanged)
Installing /usr/local/lib/perl5/5.00503/man/man3/Storable.3
Writing /tmp/i386-freebsd/auto/Storable/.packlist
Appending installation info to /tmp/i386-freebsd/perllocal.pod
fenestro% 


This appears to be a bug in ExtUtils::Install, and so should be reported
to the Perl folks, not the FreeBSD folks.

  Bill
Comment 7 Bill Fenner 1999-09-05 02:36:23 UTC
BTW, MakeMaker has a bunch of bugs.  It seems to try to take its idea of
what the paths from Config.pm should be and use s/// to turn them into
something else, but

a) it seems to get the defaults wrong -- a perl installation with
no defaults overridden at configure time (i.e. Config.pm has
"config_args=''") tries some things that will work:

prefixify INSTALLPRIVLIB (/usr/local/lib/perl5/5.00503), with /usr/local/lib/perl5 -> $(PREFIX)/lib/perl5
prefixify INSTALLARCHLIB (/usr/local/lib/perl5/5.00503/i686-linux-thread), with /usr/local/lib/perl5 -> $(PREFIX)/lib/perl5

and some that won't:

prefixify INSTALLMAN1DIR (/usr/local/man/man1), with /usr/local/lib/perl5/man -> $(PREFIX)/lib/perl5/man
prefixify INSTALLMAN3DIR (/usr/local/lib/perl5/5.00503/man/man3), with /usr/local/lib/perl5/man -> $(PREFIX)/lib/perl5/man

b) if you give args to Configure, like the FreeBSD build does, MakeMaker
doesn't take them into account so does even more things wrong:

prefixify INSTALLPRIVLIB (/usr/libdata/perl/5.00503), with /usr/lib/perl5 -> $(PREFIX)/lib/perl5
prefixify INSTALLARCHLIB (/usr/libdata/perl/5.00503/mach), with /usr/lib/perl5 -> $(PREFIX)/lib/perl5
prefixify INSTALLSITELIB (/usr/local/lib/perl5/site_perl/5.005), with /usr/lib/perl5 -> $(PREFIX)/lib/perl5
prefixify INSTALLSITEARCH (/usr/local/lib/perl5/site_perl/5.005/i386-freebsd), with /usr/lib/perl5 -> $(PREFIX)/lib/perl5
prefixify INSTALLMAN1DIR (/usr/local/man/man1), with /usr/lib/perl5/man -> $(PREFIX)/lib/perl5/man
prefixify INSTALLMAN3DIR (/usr/local/lib/perl5/5.00503/man/man3), with /usr/lib/perl5/man -> $(PREFIX)/lib/perl5/man

None of these substitutions can work.


(this output is from instrumenting ExtUtils::MM_Unix prefixify() with
print "prefixify $var ($self->{uc $var}), with $sprefix -> $rprefix\n";
)

I'm not perl-errific enough to want to get into MakeMaker deeply enough
to try to fix this, especially since it seems more or less fundamentally
broken.  Perhaps someone with more spare time and/or more perl energy
can =)

  Bill
Comment 8 Bill Fenner freebsd_committer freebsd_triage 1999-09-05 02:36:53 UTC
State Changed
From-To: open->closed

Ok, I've convinced myself that it's a perl problem (in ExtUtils::MM_Unix 
or ExtUtils::Install), which is clearly exacerbated by FreeBSD's use 
of different prefixes when configuring (but not caused by it).