Skip Menu |

This queue is for tickets about the ExtUtils-PkgConfig CPAN distribution.

Report information
The Basics
Id: 29758
Status: resolved
Priority: 0/
Queue: ExtUtils-PkgConfig

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

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



Subject: shared bug between PkgConfig and Gtk2
Gtk2 uses ExtUtils::PkgConfig which in turn uses system "pkg-config --exists --silence-errors \"$pkg\"" ) With this call any errors that might occur are hidden from the user, Makefile.PL just dies and the user has to go digging. In my case some libraries like xinerama and xmu which I had never heard of before had to be installed. That's some cheap information that should be presented to the user instead of leaving him without options to step through Makefile.PL with the debugger.
RT-Send-CC: scott [...] asofyet.org
On Thu Oct 04 00:13:32 2007, ANDK wrote: Show quoted text
> Gtk2 uses ExtUtils::PkgConfig which in turn uses > > system "pkg-config --exists --silence-errors \"$pkg\"" ) > > With this call any errors that might occur are hidden from the user, > Makefile.PL just dies and the user has to go digging.
You're right. Here's a patch that provides some diagnostics. muppet, what do you think?
Index: lib/ExtUtils/PkgConfig.pm =================================================================== RCS file: /cvsroot/gtk2-perl/gtk2-perl-xs/ExtUtils-PkgConfig/lib/ExtUtils/PkgConfig.pm,v retrieving revision 1.17 diff -u -d -p -r1.17 PkgConfig.pm --- lib/ExtUtils/PkgConfig.pm 24 Sep 2006 20:33:51 -0000 1.17 +++ lib/ExtUtils/PkgConfig.pm 6 Oct 2007 22:02:45 -0000 @@ -90,11 +90,17 @@ sub find { { if( @pkgs > 1 ) { + warn "*** pkg-config encountered these errors when trying \"$pkgs[-1]\":\n"; + system "pkg-config --print-errors \"$pkgs[-1]\""; + croak '*** can not find package for any of ('.join(', ',@pkgs).")\n" . "*** check that one of them is properly installed and available in PKG_CONFIG_PATH\n"; } else { + warn "*** pkg-config encountered these errors:\n"; + system "pkg-config --print-errors \"$pkgs[0]\""; + croak "*** can not find package $pkgs[0]\n" . "*** check that it is properly installed and available in PKG_CONFIG_PATH\n"; }
Subject: Re: [rt.cpan.org #29758] shared bug between PkgConfig and Gtk2
Date: Sun, 7 Oct 2007 01:01:28 -0400
To: bug-Gtk2 [...] rt.cpan.org
From: muppet <scott [...] asofyet.org>
On Oct 6, 2007, at 6:07 PM, Torsten Schönfeld via RT wrote: Show quoted text
> > <URL: http://rt.cpan.org/Ticket/Display.html?id=29758 > > > On Thu Oct 04 00:13:32 2007, ANDK wrote: >
>> Gtk2 uses ExtUtils::PkgConfig which in turn uses >> >> system "pkg-config --exists --silence-errors \"$pkg\"" ) >> >> With this call any errors that might occur are hidden from the user, >> Makefile.PL just dies and the user has to go digging.
> > You're right. Here's a patch that provides some diagnostics. > > muppet, what do you think?
Hrm. With the patch, if there's more than one package (@pkgs > 1), you'll only show the error messages for the last one. The --exists flag seems to imply --silence-errors by default. The point of using --exists is to find out whether the thing exists or not, which it returns through the program's exit status. ExtUtils::PkgConfig::find() allows you to search for any of a list of modules, intended for something like determining whether you have foo-1.0 or foo-2.0 installed. Unfortunately, pkg-config takes any error in searching for the package to mean that it doesn't exist, and won't print anything. For example, the not-too uncommon case that you have foo installed, but not its dependency bar: $ echo "Requires: bar" > foo.pc $ PKG_CONFIG_PATH=. pkg-config --exists foo || echo no no $ PKG_CONFIG_PATH=. pkg-config --exists --print-errors foo Package bar was not found in the pkg-config search path. Perhaps you should add the directory containing `bar.pc' to the PKG_CONFIG_PATH environment variable Package 'bar', required by './foo.pc', not found Here, the quiet mode is too quiet, and the verbose mode is too verbose. In most cases, we'll be looking for one package, and if we're looking for more than one package, they'll be in order of preference. If we can't find any of them, things are bad. But there's also the case that the one we preferred, the first, is installed, but had a parse error as shown above; the patch will not help diagnose that. I see two options: 1. Use $errs = `pkg-config --exists --print-errors --errors-to- stdout $pkg` to trap the error messages, mangle them, and print them. I don't like this option, because if the language is different, the messages may be translated, and then we're screwed. 2. Use --print-errors instead of --silence-errors on the --exists calls, to dump the errors immediately. This will have potential to generate lots of unwanted spew, but, well, what can you do? I say go for 2. In either case, the logic in find()'s "i couldn't find anything at all" section should just loop over all of the failed packages instead of trying to special-case the only-one case for grammar. -- One, two, free, four, five, six, sebben, eight, nine, ten, elebben, twull, fourteen, sickteen, sebbenteen, eightteen, elebbenteen, fiffeen, elebbenteen! -- Zella, aged three, counting to twenty.
On Sun Oct 07 01:01:38 2007, scott@asofyet.org wrote: Show quoted text
> I see two options: > > 1. Use $errs = `pkg-config --exists --print-errors --errors-to- > stdout $pkg` to trap the error messages, mangle them, and print > them. I don't like this option, because if the language is > different, the messages may be translated, and then we're screwed. > > 2. Use --print-errors instead of --silence-errors on the --exists > calls, to dump the errors immediately. This will have potential to > generate lots of unwanted spew, but, well, what can you do? > > > I say go for 2.
Sounds good. Patch attached. Show quoted text
> In either case, the logic in find()'s "i couldn't find anything at > all" section should just loop over all of the failed packages instead > of trying to special-case the only-one case for grammar.
Well, the difference between the two cases is not only gramatical. If there is more than one alternative listed, the error messages correctly says that none could be found and that the user should install _one_ of them. When you just loop over the packages, the user will effectively be told to install all of them.
Index: PkgConfig.pm =================================================================== RCS file: /cvsroot/gtk2-perl/gtk2-perl-xs/ExtUtils-PkgConfig/lib/ExtUtils/PkgConfig.pm,v retrieving revision 1.17 diff -u -d -p -r1.17 PkgConfig.pm --- PkgConfig.pm 24 Sep 2006 20:33:51 -0000 1.17 +++ PkgConfig.pm 7 Oct 2007 17:46:15 -0000 @@ -80,7 +80,7 @@ sub find { # try as many pkg parameters are there are arguments left on stack while( $pkg and - system "pkg-config --exists --silence-errors \"$pkg\"" ) + system "pkg-config --exists --print-errors \"$pkg\"" ) { push @pkgs, $pkg; $pkg = shift;
CC: bug-Gtk2 [...] rt.cpan.org
Subject: Re: [rt.cpan.org #29758] shared bug between PkgConfig and Gtk2
Date: Thu, 18 Oct 2007 18:13:09 +0200
To: muppet <scott [...] asofyet.org>
From: Torsten Schoenfeld <kaffeetisch [...] gmx.de>
On Sun, 2007-10-07 at 01:01 -0400, muppet wrote: Show quoted text
> I say go for 2. > > > In either case, the logic in find()'s "i couldn't find anything at > all" section should just loop over all of the failed packages instead > of trying to special-case the only-one case for grammar.
It just occurred to me that you probably haven't seen my reply, since I forgot to put you in CC: <http://rt.cpan.org/Ticket/Display.html?id=29758> -- Bye, -Torsten
CC: bug-Gtk2 [...] rt.cpan.org
Subject: Re: [rt.cpan.org #29758] shared bug between PkgConfig and Gtk2
Date: Thu, 18 Oct 2007 21:39:40 -0400
To: Torsten Schoenfeld <kaffeetisch [...] gmx.de>
From: muppet <scott [...] asofyet.org>
On Oct 18, 2007, at 12:13 PM, Torsten Schoenfeld wrote: Show quoted text
> It just occurred to me that you probably haven't seen my reply, > since I > forgot to put you in CC: > <http://rt.cpan.org/Ticket/Display.html?id=29758>
I hadn't, thanks. Patch looks good to me. -- The stereo, playing the Beastie Boys' "Rhymin' and Stealin'": "I'll steal your girlie like I stole your bike!" Elysse: "You mean, take off the chain and ride away?"
On Thu Oct 18 21:39:27 2007, scott@asofyet.org wrote: Show quoted text
> Patch looks good to me.
Committed. I can't roll a release just yet since I lack the proper CPAN namespace permissions, but I asked Marc and Ross to either do it themselves or to make me co-maintainer.