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.