Skip Menu |
 

This queue is for tickets about the Find-Lib CPAN distribution.

Report information
The Basics
Id: 66049
Status: open
Priority: 0/
Queue: Find-Lib

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

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



Subject: Find::Lib and symlinks
Download (untitled) / with headers
text/plain 834b
Find::Lib touts its handling of symlinks, but it fails to handle symlinks to the script. $ find ! -type d -exec ls -dl {} + lrwxrwxrwx 1 eric users 8 Feb 22 17:04 ./a.pl -> bin/a.pl -rwx------ 1 eric users 53 Feb 22 17:04 ./bin/a.pl -rw------- 1 eric users 16 Feb 22 17:03 ./lib/Mod.pm $ cat bin/a.pl #!/usr/bin/env perl use Find::Lib '../lib'; use Mod; $ cat lib/Mod.pm package Mod; 1; $ bin/a.pl $ a.pl Can't locate Mod.pm in @INC (@INC contains: /home/eric/usr/perlbrew/perls/perl-5.12.2/lib/site_perl/5.12.2/i686-linux /home/eric/usr/perlbrew/perls/perl-5.12.2/lib/site_perl/5.12.2 /home/eric/usr/perlbrew/perls/perl-5.12.2/lib/5.12.2/i686-linux /home/eric/usr/perlbrew/perls/perl-5.12.2/lib/5.12.2 .) at ./a.pl line 3. BEGIN failed--compilation aborted at ./a.pl line 3. $ perl -MFind::Lib -E'say Find::Lib->VERSION' 1.01
Download (untitled) / with headers
text/plain 124b
Workaround: use Cwd qw( realpath ); use File::Basename qw( dirname ); use lib dirname(realpath($0)).'/../lib';
Download (untitled) / with headers
text/plain 214b
I don't think I have a unit test when the binary itself is linked, only when the directories the binary is in, but it's been a while, I'll have to refresh my memory. The usecase is a little bit odd though, right?
CC: IKEGAMI [...] cpan.org
Subject: Re: [rt.cpan.org #66049] Find::Lib and symlinks
Date: Tue, 22 Feb 2011 18:40:31 -0500
To: bug-Find-Lib [...] rt.cpan.org
From: Eric Brine <ikegami [...] adaelis.com>
Download (untitled) / with headers
text/plain 489b
On Tue, Feb 22, 2011 at 5:47 PM, Yann Kerherve via RT < bug-Find-Lib@rt.cpan.org> wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=66049 > > > I don't think I have a unit test when the binary itself is linked, only > when the directories the > binary is in, but it's been a while, I'll have to refresh my memory. > > The usecase is a little bit odd though, right? >
I wouldn't call linking to an executable odd at all. For example, /usr/bin/perl is a link (albeit a hard one).
Download (untitled) / with headers
text/plain 272b
If you symlink your a.pl then you 'lib' path will need to be offset too. Find::Lib uses $0 to interpret what the caller is trying to do. If you call a symlink Find::Lib interprets that as the new home execution environment and purposely doesn't resolve it to realpath().
CC: IKEGAMI [...] cpan.org
Subject: Re: [rt.cpan.org #66049] Find::Lib and symlinks
Date: Wed, 29 Jun 2011 15:41:50 -0400
To: bug-Find-Lib [...] rt.cpan.org
From: Eric Brine <ikegami [...] adaelis.com>
Download (untitled) / with headers
text/plain 543b
On Wed, Jun 29, 2011 at 2:10 PM, Yann Kerherve via RT < bug-Find-Lib@rt.cpan.org> wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=66049 > > > If you symlink your a.pl then you 'lib' path will need to be offset too. > Find::Lib uses $0 to > interpret what the caller is trying to do. If you call a symlink Find::Lib > interprets that as the new > home execution environment and purposely doesn't resolve it to realpath(). >
You're saying it's not acceptable to do ln -s ~/usr/app/bin/app ~/bin/app and that's just baffling to me.
CC: IKEGAMI [...] cpan.org
Subject: Re: [rt.cpan.org #66049] Find::Lib and symlinks
Date: Wed, 29 Jun 2011 18:10:23 -0400
To: bug-Find-Lib [...] rt.cpan.org
From: Eric Brine <ikegami [...] adaelis.com>
Download (untitled) / with headers
text/plain 909b
On Wed, Jun 29, 2011 at 3:42 PM, ikegami@adaelis.com via RT < bug-Find-Lib@rt.cpan.org> wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=66049 > > > On Wed, Jun 29, 2011 at 2:10 PM, Yann Kerherve via RT < > bug-Find-Lib@rt.cpan.org> wrote: >
> > <URL: https://rt.cpan.org/Ticket/Display.html?id=66049 > > > > > If you symlink your a.pl then you 'lib' path will need to be offset too. > > Find::Lib uses $0 to > > interpret what the caller is trying to do. If you call a symlink
> Find::Lib
> > interprets that as the new > > home execution environment and purposely doesn't resolve it to
> realpath().
> >
> > You're saying it's not acceptable to do > > ln -s ~/usr/app/bin/app ~/bin/app > > and that's just baffling to me. >
If someone wants the behaviour you describe, they can already get it using either of ln ~/usr/app/bin/app ~/exec_env/bin/app and cp ~/usr/app/bin/app ~/exec_env/bin/app
Download (untitled) / with headers
text/plain 432b
I'm not saying you are wrong, I'm saying that it's two different use cases and that Find::Lib originally intended to solve the other one. And more importantly, it was meant to be intuitive for a script to refer to a lib relatively to $0 even if there are symlinks in this relative expression. I've tried what to solve for your problem, here is how it might look: https://github.com/yannk/findlib/tree/resolve What do you think?
CC: IKEGAMI [...] cpan.org
Subject: Re: [rt.cpan.org #66049] Find::Lib and symlinks
Date: Wed, 13 Jul 2011 04:18:36 -0400
To: bug-Find-Lib [...] rt.cpan.org
From: Eric Brine <ikegami [...] adaelis.com>
Download (untitled) / with headers
text/plain 516b
On Fri, Jul 1, 2011 at 12:45 AM, Yann Kerherve via RT < bug-Find-Lib@rt.cpan.org> wrote: Show quoted text
Show quoted text
> I've tried what to solve for your problem, here is how it might look: > https://github.com/yannk/findlib/tree/resolve > > What do you think? >
From looking at the code, it appears to do what I want. I haven't gotten back to you because I was going to include a patch for tests and documentation in my reply, but I got too many things on the go. Thanks, Eric


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

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