This queue is for tickets about the CPAN CPAN distribution.

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

People
Owner:
Nobody in particular
Requestors:
jeff.holt [...] method-r.com
Cc:
AdminCc:

BugTracker
Severity:
(no value)
Broken in:
(no value)
Fixed in:
(no value)



Subject: App::Cpan->run() fails if you chdir after the use
Date: Fri, 26 Jul 2013 11:13:54 -0500
To: bug-CPAN@rt.cpan.org
From: Jeff Holt <jeff.holt@method-r.com>
I have a need to build modules of indeterminate type (MM or MB) and it seems reasonable to use "cpan -ft ." to do so. The pod for App::Cpan declares no constraints upon the caller except, by inference, that @ARGV must be set properly before calling App::Cpan->run().

The problem I have is that I want to make many modules in the same execution. So, one should expect the code to look something like this:

Show quoted text
use App::Cpan;
for (@modules) {
   chdir($_);
   App::Cpan->run("-t", ".");
}

Well, that doesn't work because I get a cpan> prompt. I had to reread the pod to figure out that run (and its descendants) use @ARGV. Really? Ok, I'll do the un-perly thing to move forward.

Show quoted text
use App::Cpan;
for (@modules) {
   chdir($_);
   @ARGV = qw(-t .);
   App::Cpan->run();
}

Well, that still doesn't work because it thinks the "working directory" is the current directory at the time of the "use". I had to reread the CPAN.pm code to figure out that it sets a global variable $CPAN::iCwd to the current working directory at BEGIN time. Really? Ok, I'll do the un-perly thing to move forward.

Here's the code that finally works. But I haven't read ALL the code to know if it will always work. That's what bothers me the most.

Show quoted text
Show quoted text
use App::Cpan;
use Cwd;
for (@modules) {
   chdir($_);
   @ARGV = qw(-t .);
   $CPAN::iCwd = cwd;
   App::Cpan->run();
}
 
I have no idea why CPAN.pm and its indirect (direct?) caller App::Cpan do it the way they do. But it doesn't smell very good. Sorry for the bluntness but I don't think my comments are out of line given the workaround and the hack that I've had to employ.

If you believe that these two idiosyncrasies are legitimate bugs, let me know and I'll spend an hour to estimate the work required to provide a fix.
CC: undisclosed-recipients:;
Subject: Re: [rt.cpan.org #87356] App::Cpan->run() fails if you chdir after the use
Date: Sat, 27 Jul 2013 13:58:04 +0200
To: bug-CPAN@rt.cpan.org
From: Andreas Koenig <andreas.koenig.7os6VVqR@franz.ak.mind.de>
"Jeff Holt via RT" <bug-CPAN@rt.cpan.org> writes:
Show quoted text
> [snip] > Here's the code that finally works. But I haven't read ALL the code to know > if it will always work. That's what bothers me the most. > > use App::Cpan; > use Cwd; > for (@modules) { > chdir($_); > @ARGV = qw(-t .); > $CPAN::iCwd = cwd; > App::Cpan->run(); > }
I can feel your pain. Before jumping to conclusions I offer a different view on it. I believe that App::Cpan was invented to support "cpan", the small program that is to be called on the command line. I would expect best results with it when used lime on the the commandline, as a forking system call. So I would expect that it works nicely with something like: my $cwd = cwd; for (@modules) { 0==system cpan => "-t", "$cwd/$_/." or die "problem running $_"; } Opinions anyone?
Show quoted text
> I have no idea why CPAN.pm and its indirect (direct?) caller App::Cpan do > it the way they do. But it doesn't smell very good. Sorry for the bluntness > but I don't think my comments are out of line given the workaround and the > hack that I've had to employ.
First guess is that the solution you found should be discouraged by some documentation somewhere. Second guess is that there might be some fixes possible to make your initial vision possible which was:
Show quoted text
> use App::Cpan; > for (@modules) { > chdir($_); > App::Cpan->run("-t", "."); > }
I'm not sure whether it is a desirable solution, there may be tradeoffs.
Show quoted text
> If you believe that these two idiosyncrasies are legitimate bugs, let me > know and I'll spend an hour to estimate the work required to provide a > fix.
We probably should hear more voices before we decide which direction is preferrable/preferred. -- andreas
Subject: Re: [rt.cpan.org #87356] App::Cpan->run() fails if you chdir after the use
Date: Sat, 27 Jul 2013 08:02:02 -0500
To: bug-CPAN@rt.cpan.org
From: Jeff Holt <jeff.holt@method-r.com>
If there is a better module for what I am doing, then I have no problem with someone removing the entire pod for App::Cpan. I didn't find any pod for the other candidates and having found it only for App::Cpan, I assumed it was the one to use.

Calling system(qw(cpan -t .)), worked only on linux, solaris, and darwin. I ran into all kinds of problems with windows and thought using App::Cpan would be a big time saver.


On Sat, Jul 27, 2013 at 7:00 AM, (Andreas J. Koenig) via RT <bug-CPAN@rt.cpan.org> wrote:
Show quoted text
<URL: https://rt.cpan.org/Ticket/Display.html?id=87356 >

"Jeff Holt via RT" <bug-CPAN@rt.cpan.org> writes:

> [snip]
> Here's the code that finally works. But I haven't read ALL the code to know
> if it will always work. That's what bothers me the most.
>
> use App::Cpan;
> use Cwd;
> for (@modules) {
>    chdir($_);
>    @ARGV = qw(-t .);
>    $CPAN::iCwd = cwd;
>    App::Cpan->run();
> }

I can feel your pain. Before jumping to conclusions I offer a different
view on it. I believe that App::Cpan was invented to support "cpan", the
small program that is to be called on the command line. I would expect
best results with it when used lime on the the commandline, as a forking
system call. So I would expect that it works nicely with something like:

my $cwd = cwd;
for (@modules) {
   0==system cpan => "-t", "$cwd/$_/." or die "problem running $_";
}

Opinions anyone?

> I have no idea why CPAN.pm and its indirect (direct?) caller App::Cpan do
> it the way they do. But it doesn't smell very good. Sorry for the bluntness
> but I don't think my comments are out of line given the workaround and the
> hack that I've had to employ.

First guess is that the solution you found should be discouraged by some
documentation somewhere. Second guess is that there might be some fixes
possible to make your initial vision possible which was:

> use App::Cpan;
> for (@modules) {
>    chdir($_);
>    App::Cpan->run("-t", ".");
> }

I'm not sure whether it is a desirable solution, there may be tradeoffs.

> If you believe that these two idiosyncrasies are legitimate bugs, let me
> know and I'll spend an hour to estimate the work required to provide a
> fix.

We probably should hear more voices before we decide which direction is
preferrable/preferred.

--
andreas


Subject: Re: [rt.cpan.org #87356] App::Cpan->run() fails if you chdir after the use
Date: Sat, 27 Jul 2013 19:04:31 +0200
To: bug-CPAN@rt.cpan.org
From: Andreas Koenig <andreas.koenig.7os6VVqR@franz.ak.mind.de>
"Jeff Holt via RT" <bug-CPAN@rt.cpan.org> writes:
Show quoted text
> Queue: CPAN > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=87356 > > > If there is a better module for what I am doing, then I have no problem > with someone removing the entire pod for App::Cpan. I didn't find any pod > for the other candidates and having found it only for App::Cpan, I assumed > it was the one to use.
I can't blame you for doing so:/ I'm strongly in favor of adding documentation that leads you to the right approach. I regret that CPAN.pm is underdocumented. How about: my @modules = qw(devel-symdump javascript-v8); use Cwd; my $cwd = cwd; use File::Spec; my @targets = map { File::Spec->catdir($cwd, $_) . "/." } @modules; use CPAN; CPAN::Shell->test(@targets); Just tested it a little bit and I'm not sure what you will be missing (e.g. rel2abs), but it's a start.
Show quoted text
> Calling system(qw(cpan -t .)), worked only on linux, solaris, and darwin. I > ran into all kinds of problems with windows and thought using App::Cpan > would be a big time saver.
Maybe it is and I'm just not the right person to judge that. -- andreas
Subject: Re: [rt.cpan.org #87356] App::Cpan->run() fails if you chdir after the use
Date: Sat, 27 Jul 2013 13:11:43 -0500
To: bug-CPAN@rt.cpan.org
From: Jeff Holt <jeff.holt@method-r.com>
I'm afraid CPAN::Shell->test doesn't work either, probably because it relies upon the same code that uses the global variable that App::Cpan->run uses.

I believe App::Cpan->run, when @ARGV = qw(-t .), eventually calls the same code that CPAN::Shell->test calls.

According to the higher level methods, there's only one predicate that triggers the processing of a directory that has been "prepared" from source. That predicate compares the given argument to the string ".". Seems reasonable that the predicate could be enhanced to include not just "." but also any string that is an absolute pathname.

Expanding that predicate wouldn't fix the whole problem, though, since the next call normalizes the string by incorporating $CPAN::iCwd.


On Sat, Jul 27, 2013 at 12:04 PM, (Andreas J. Koenig) via RT <bug-CPAN@rt.cpan.org> wrote:
Show quoted text
>        Queue: CPAN
>  Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=87356 >
>
> If there is a better module for what I am doing, then I have no problem
> with someone removing the entire pod for App::Cpan. I didn't find any pod
> for the other candidates and having found it only for App::Cpan, I assumed
> it was the one to use.

I can't blame you for doing so:/

I'm strongly in favor of adding documentation that leads you to the
right approach. I regret that CPAN.pm is underdocumented. How about:

  my @modules = qw(devel-symdump javascript-v8);
  use Cwd;
  my $cwd = cwd;
  use File::Spec;
  my @targets = map { File::Spec->catdir($cwd, $_) . "/." } @modules;
  use CPAN;
  CPAN::Shell->test(@targets);

Just tested it a little bit and I'm not sure what you will be missing
(e.g. rel2abs), but it's a start.

> Calling system(qw(cpan -t .)), worked only on linux, solaris, and darwin. I
> ran into all kinds of problems with windows and thought using App::Cpan
> would be a big time saver.

Maybe it is and I'm just not the right person to judge that.

--
andreas


Subject: Re: [rt.cpan.org #87356] App::Cpan->run() fails if you chdir after the use
Date: Sat, 27 Jul 2013 13:31:01 -0500
To: bug-CPAN@rt.cpan.org
From: Jeff Holt <jeff.holt@method-r.com>
I should also expand what I meant in my original post when I mentioned indeterminate modules. The repository management code I'm working on must handle modules hosted by cpan.org (and dependencies) that my code needs. I have a list of 10 or so that my code depends upon.

It also needs to handle modules that we are not allowed to share with anyone else. Those are stored in our svn repository. This latter set of modules are the ones that are causing the problem because, at least to the best of my knowledge, we don't know how to tell CPAN.pm that our source repository is another source code repository just like cpan.org.

So that's why we are using the documented method for making cpan execute "make test" in the current directory.

I wasn't sure if you were aware of the whole context that has brought me to log the bug.


On Sat, Jul 27, 2013 at 1:11 PM, Jeff Holt <jeff.holt@method-r.com> wrote:
Show quoted text
I'm afraid CPAN::Shell->test doesn't work either, probably because it relies upon the same code that uses the global variable that App::Cpan->run uses.

I believe App::Cpan->run, when @ARGV = qw(-t .), eventually calls the same code that CPAN::Shell->test calls.

According to the higher level methods, there's only one predicate that triggers the processing of a directory that has been "prepared" from source. That predicate compares the given argument to the string ".". Seems reasonable that the predicate could be enhanced to include not just "." but also any string that is an absolute pathname.

Expanding that predicate wouldn't fix the whole problem, though, since the next call normalizes the string by incorporating $CPAN::iCwd.


On Sat, Jul 27, 2013 at 12:04 PM, (Andreas J. Koenig) via RT <bug-CPAN@rt.cpan.org> wrote:
>        Queue: CPAN
>  Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=87356 >
>
> If there is a better module for what I am doing, then I have no problem
> with someone removing the entire pod for App::Cpan. I didn't find any pod
> for the other candidates and having found it only for App::Cpan, I assumed
> it was the one to use.

I can't blame you for doing so:/

I'm strongly in favor of adding documentation that leads you to the
right approach. I regret that CPAN.pm is underdocumented. How about:

  my @modules = qw(devel-symdump javascript-v8);
  use Cwd;
  my $cwd = cwd;
  use File::Spec;
  my @targets = map { File::Spec->catdir($cwd, $_) . "/." } @modules;
  use CPAN;
  CPAN::Shell->test(@targets);

Just tested it a little bit and I'm not sure what you will be missing
(e.g. rel2abs), but it's a start.

> Calling system(qw(cpan -t .)), worked only on linux, solaris, and darwin. I
> ran into all kinds of problems with windows and thought using App::Cpan
> would be a big time saver.

Maybe it is and I'm just not the right person to judge that.

--
andreas



Subject: Re: [rt.cpan.org #87356] App::Cpan->run() fails if you chdir after the use
Date: Sat, 27 Jul 2013 21:14:04 +0200
To: bug-CPAN@rt.cpan.org
From: Andreas Koenig <andreas.koenig.7os6VVqR@franz.ak.mind.de>
"Jeff Holt via RT" <bug-CPAN@rt.cpan.org> writes:
Show quoted text
> Queue: CPAN > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=87356 > > > I'm afraid CPAN::Shell->test doesn't work either, probably because it > relies upon the same code that uses the global variable that App::Cpan->run > uses.
You seem to have misread my postings.
Show quoted text
> I believe App::Cpan->run, when @ARGV = qw(-t .), eventually calls the same > code that CPAN::Shell->test calls.
Note that I did not use qw(-t .) in my examples.
Show quoted text
> According to the higher level methods, there's only one predicate that > triggers the processing of a directory that has been "prepared" from > source. That predicate compares the given argument to the string ".". Seems > reasonable that the predicate could be enhanced to include not just "." but > also any string that is an absolute pathname.
And this is what CPAN.pm does already.
Show quoted text
> Expanding that predicate wouldn't fix the whole problem, though, since the > next call normalizes the string by incorporating $CPAN::iCwd.
Maybe it would help to try my examples out, at least those where I say that I tried them out:) "Jeff Holt via RT" <bug-CPAN@rt.cpan.org> writes:
Show quoted text
> Queue: CPAN > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=87356 > > > I should also expand what I meant in my original post when I mentioned > indeterminate modules. The repository management code I'm working on must > handle modules hosted by cpan.org (and dependencies) that my code needs. I > have a list of 10 or so that my code depends upon.
As this is a separate problem that reaches the realms of local::lib or CPAN::Site or other modules that will help you with this problem, I suggest you focus on the part that deals with published CPAN modules first. -- andreas
CC: undisclosed-recipients:;
Subject: Re: [rt.cpan.org #87356] App::Cpan->run() fails if you chdir after the use
Date: Sat, 27 Jul 2013 21:13:50 +0200
To: bug-CPAN@rt.cpan.org
From: Andreas Koenig <andreas.koenig.7os6VVqR@franz.ak.mind.de>
"Jeff Holt via RT" <bug-CPAN@rt.cpan.org> writes:
Show quoted text
> Queue: CPAN > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=87356 > > > I'm afraid CPAN::Shell->test doesn't work either, probably because it > relies upon the same code that uses the global variable that App::Cpan->run > uses.
You seem to have misread my postings.
Show quoted text
> I believe App::Cpan->run, when @ARGV = qw(-t .), eventually calls the same > code that CPAN::Shell->test calls.
Note that I did not use qw(-t .) in my examples.
Show quoted text
> According to the higher level methods, there's only one predicate that > triggers the processing of a directory that has been "prepared" from > source. That predicate compares the given argument to the string ".". Seems > reasonable that the predicate could be enhanced to include not just "." but > also any string that is an absolute pathname.
And this is what CPAN.pm does already.
Show quoted text
> Expanding that predicate wouldn't fix the whole problem, though, since the > next call normalizes the string by incorporating $CPAN::iCwd.
Maybe it would help to try my examples out, at least those where I say that I tried them out:) "Jeff Holt via RT" <bug-CPAN@rt.cpan.org> writes:
Show quoted text
> Queue: CPAN > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=87356 > > > I should also expand what I meant in my original post when I mentioned > indeterminate modules. The repository management code I'm working on must > handle modules hosted by cpan.org (and dependencies) that my code needs. I > have a list of 10 or so that my code depends upon.
As this is a separate problem that reaches the realms of local::lib or CPAN::Site or other modules that will help you with this problem, I suggest you focus on the part that deals with published CPAN modules first. -- andreas
Subject: Re: [rt.cpan.org #87356] App::Cpan->run() fails if you chdir after the use
Date: Mon, 29 Jul 2013 16:26:34 -0500
To: bug-CPAN@rt.cpan.org
From: Jeff Holt <jeff.holt@method-r.com>
I'm sorry if I misread your postings but I thought I was pretty careful in transposing what you wrote. I'll give you more detail regarding exactly what I did and you can tell me where I went wrong. By way of overview, I copied your code verbatim to a file called t.pl. Then I executed "perl t.pl". What I got is as follows. My shell prompt is "$ ".

$ perl t.pl
You are visiting the local directory
  '/Users/jholt/devel-symdump/.'
  without lock, take care that concurrent processes do not do likewise.
Reading '/Users/jholt/.cpan/Metadata'
  Database was generated on Sat, 27 Jul 2013 10:41:03 GMT
Fetching with LWP:
Reading '/Users/jholt/.cpan/sources/authors/01mailrc.txt.gz'
............................................................................DONE
Fetching with LWP:
Reading '/Users/jholt/.cpan/sources/modules/02packages.details.txt.gz'
  Database was generated on Mon, 29 Jul 2013 11:17:02 GMT
............................................................................DONE
Fetching with LWP:
Reading '/Users/jholt/.cpan/sources/modules/03modlist.data.gz'
............................................................................DONE
Writing /Users/jholt/.cpan/Metadata
You are visiting the local directory
  '/Users/jholt/javascript-v8/.'
  without lock, take care that concurrent processes do not do likewise.
Running make for /Users/jholt/devel-symdump/.
Couldn't opendir /Users/jholt/devel-symdump/.: No such file or directory at /usr/local/ActivePerl-5.16/site/lib/CPAN/Shell.pm line 1797.
$ cat t.pl
my @modules = qw(devel-symdump javascript-v8);
  use Cwd;
  my $cwd = cwd;
  use File::Spec;
  my @targets = map { File::Spec->catdir($cwd, $_) . "/." } @modules;
  use CPAN;
  CPAN::Shell->test(@targets);
$


On Sat, Jul 27, 2013 at 2:14 PM, (Andreas J. Koenig) via RT <bug-CPAN@rt.cpan.org> wrote:
Show quoted text
<URL: https://rt.cpan.org/Ticket/Display.html?id=87356 >

"Jeff Holt via RT" <bug-CPAN@rt.cpan.org> writes:

>        Queue: CPAN
>  Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=87356 >
>
> I'm afraid CPAN::Shell->test doesn't work either, probably because it
> relies upon the same code that uses the global variable that App::Cpan->run
> uses.

You seem to have misread my postings.

> I believe App::Cpan->run, when @ARGV = qw(-t .), eventually calls the same
> code that CPAN::Shell->test calls.

Note that I did not use qw(-t .) in my examples.

> According to the higher level methods, there's only one predicate that
> triggers the processing of a directory that has been "prepared" from
> source. That predicate compares the given argument to the string ".". Seems
> reasonable that the predicate could be enhanced to include not just "." but
> also any string that is an absolute pathname.

And this is what CPAN.pm does already.

> Expanding that predicate wouldn't fix the whole problem, though, since the
> next call normalizes the string by incorporating $CPAN::iCwd.

Maybe it would help to try my examples out, at least those where I say
that I tried them out:)

"Jeff Holt via RT" <bug-CPAN@rt.cpan.org> writes:

>        Queue: CPAN
>  Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=87356 >
>
> I should also expand what I meant in my original post when I mentioned
> indeterminate modules. The repository management code I'm working on must
> handle modules hosted by cpan.org (and dependencies) that my code needs. I
> have a list of 10 or so that my code depends upon.

As this is a separate problem that reaches the realms of local::lib or
CPAN::Site or other modules that will help you with this problem, I
suggest you focus on the part that deals with published CPAN modules
first.

--
andreas


Subject: Re: [rt.cpan.org #87356] App::Cpan->run() fails if you chdir after the use
Date: Tue, 30 Jul 2013 04:16:18 +0200
To: bug-CPAN@rt.cpan.org
From: Andreas Koenig <andreas.koenig.7os6VVqR@franz.ak.mind.de>
"Jeff Holt via RT" <bug-CPAN@rt.cpan.org> writes:
Show quoted text
> Queue: CPAN > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=87356 > > > I'm sorry if I misread your postings but I thought I was pretty careful in > transposing what you wrote. I'll give you more detail regarding exactly > what I did and you can tell me where I went wrong. By way of overview, I > copied your code verbatim to a file called t.pl. Then I executed "perl t.pl".
Show quoted text
> [...] > > $ cat t.pl > my @modules = qw(devel-symdump javascript-v8);
The two directories above exist on my machine, unsurprisingly, they do not exist on yours. They are placeholders for two directories containing perl modules, like I understood you were using the variable @modules in your examples in this ticket so far. -- andreas
Subject: Re: [rt.cpan.org #87356] App::Cpan->run() fails if you chdir after the use
Date: Mon, 29 Jul 2013 22:47:13 -0500
To: bug-CPAN@rt.cpan.org
From: Jeff Holt <jeff.holt@method-r.com>
I was quite certain that I tested the approach you used (i.e., concatenating "/." onto the module directory name. Apparently I didn't because your method works.

I believe you should close this case, with my apologies.


On Mon, Jul 29, 2013 at 9:16 PM, (Andreas J. Koenig) via RT <bug-CPAN@rt.cpan.org> wrote:
Show quoted text
<URL: https://rt.cpan.org/Ticket/Display.html?id=87356 >

"Jeff Holt via RT" <bug-CPAN@rt.cpan.org> writes:

>        Queue: CPAN
>  Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=87356 >
>
> I'm sorry if I misread your postings but I thought I was pretty careful in
> transposing what you wrote. I'll give you more detail regarding exactly
> what I did and you can tell me where I went wrong. By way of overview, I
> copied your code verbatim to a file called t.pl. Then I executed "perl t.pl".

> [...]
>
> $ cat t.pl
> my @modules = qw(devel-symdump javascript-v8);

The two directories above exist on my machine, unsurprisingly, they do
not exist on yours. They are placeholders for two directories containing
perl modules, like I understood you were using the variable @modules in
your examples in this ticket so far.

--
andreas


Thank you, closing ticket. If you have an idea where we should tweak the documentation such that the next user has a better chance to survive, let us know. Best wishes,


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.