Most operations with g-cpan will emit a bunch of error messages like these: Possible precedence issue with control flow operator at /usr/lib64/perl5/vendor_perl/5.20.1/Shell/EnvImporter/Result.pm line 88. Use of uninitialized value $_[1] in read at /usr/lib64/perl5/5.20.1/x86_64-linux-thread-multi/IO/Handle.pm line 463. [The line above is repeated 10 times] Running things through "perl -d" I get stack traces for these error messages: Possible precedence issue with control flow operator at /usr/lib64/perl5/vendor_perl/5.20.1/Shell/EnvImporter/Result.pm line 88. at /usr/lib64/perl5/vendor_perl/5.20.1/Shell/EnvImporter/Result.pm line 88. require Shell/EnvImporter/Result.pm called at /usr/lib64/perl5/vendor_perl/5.20.1/Shell/EnvImporter/Shell.pm line 10 Shell::EnvImporter::Shell::BEGIN() called at /usr/lib64/perl5/vendor_perl/5.20.1/Shell/EnvImporter/Result.pm line 88 eval {...} called at /usr/lib64/perl5/vendor_perl/5.20.1/Shell/EnvImporter/Result.pm line 88 require Shell/EnvImporter/Shell.pm called at /usr/lib64/perl5/vendor_perl/5.20.1/Shell/EnvImporter.pm line 11 Shell::EnvImporter::BEGIN() called at /usr/lib64/perl5/vendor_perl/5.20.1/Shell/EnvImporter/Result.pm line 88 eval {...} called at /usr/lib64/perl5/vendor_perl/5.20.1/Shell/EnvImporter/Result.pm line 88 require Shell/EnvImporter.pm called at /usr/lib64/perl5/vendor_perl/5.20.1/Gentoo/Portage.pm line 11 Gentoo::Portage::BEGIN() called at /usr/lib64/perl5/vendor_perl/5.20.1/Shell/EnvImporter/Result.pm line 88 eval {...} called at /usr/lib64/perl5/vendor_perl/5.20.1/Shell/EnvImporter/Result.pm line 88 require Gentoo/Portage.pm called at /usr/lib64/perl5/vendor_perl/5.20.1/Gentoo.pm line 12 Gentoo::BEGIN() called at /usr/lib64/perl5/vendor_perl/5.20.1/Shell/EnvImporter/Result.pm line 88 eval {...} called at /usr/lib64/perl5/vendor_perl/5.20.1/Shell/EnvImporter/Result.pm line 88 require Gentoo.pm called at /usr/bin/g-cpan line 81 main::BEGIN() called at /usr/lib64/perl5/vendor_perl/5.20.1/Shell/EnvImporter/Result.pm line 88 eval {...} called at /usr/lib64/perl5/vendor_perl/5.20.1/Shell/EnvImporter/Result.pm line 88 Use of uninitialized value $_[1] in read at /usr/lib64/perl5/5.20.1/x86_64-linux-thread-multi/IO/Handle.pm line 463. at /usr/lib64/perl5/5.20.1/x86_64-linux-thread-multi/IO/Handle.pm line 463. IO::Handle::read(IO::Handle=GLOB(0x3cbc0b0), undef, 4096, undef) called at /usr/lib64/perl5/vendor_perl/5.20.1/Shell/EnvImporter/Shell.pm line 198 Shell::EnvImporter::Shell::execute(Shell::EnvImporter::Shell::bash=HASH(0x3cbbe70), "bash", "-norc", "-noprofile", "-c", "echo \"1413874751_29004_9438021 0\";. '/etc/portage/make.conf';"...) called at /usr/lib64/perl5/vendor_perl/5.20.1/Shell/EnvImporter/Shell.pm line 119 Shell::EnvImporter::Shell::run(Shell::EnvImporter::Shell::bash=HASH(0x3cbbe70), "command", ". '/etc/portage/make.conf'") called at /usr/lib64/perl5/vendor_perl/5.20.1/Shell/EnvImporter.pm line 107 Shell::EnvImporter::run(Shell::EnvImporter=HASH(0x3bbb4e0)) called at /usr/lib64/perl5/vendor_perl/5.20.1/Shell/EnvImporter.pm line 88 Shell::EnvImporter::init(Shell::EnvImporter=HASH(0x3bbb4e0), "file", "/etc/portage/make.conf", "shell", "bash", "import_filter", CODE(0x3c6d888)) called at blib/lib/Class/MethodMaker/Engine.pm (autosplit into blib/lib/auto/Class/MethodMaker/Engine/new.al) line 957 Shell::EnvImporter::new("Shell::EnvImporter", "file", "/etc/portage/make.conf", "shell", "bash", "import_filter", CODE(0x3c6d888)) called at /usr/lib64/perl5/vendor_perl/5.20.1/Gentoo/Portage.pm line 52 Gentoo::Portage::getEnv(Gentoo=HASH(0x3587338), "GCPAN_CAT") called at /usr/bin/g-cpan line 220 The precedence issue is from this function here: ############### sub succeeded { ############### my $self = shift; return $self->shell_status == 0 and $self->command_status == 0 and $self->env_status == 0; } I guess that this gets parsed as (return $self->shell_status == 0) and ($self->command_status == 0) and ($self->env_status == 0); in which case the complaint would be justified. That can be fixed by adding parentheses and/or changing the "and" to "&&". The other warning comes from this code here: my $s = IO::Select->new($fh{'STDOUT'}, $fh{'STDERR'}); my $t0 = time; my %buf; while (1) { my @ready = $s->can_read(); last unless (@ready); foreach my $ready (@ready) { my $pipename = $h2p{"$ready"}; if ($ready->eof) { $s->remove($ready); last unless ($s->count); } else { $ready->read($buf{$pipename}, BLKSIZE, length($buf{$pipename})); } } } This is really bad code. $t0 is never used. The "last" only exits the inner "forach" loop, not the "while". But the problem at hand is the fact that %buf is not initialized. Apparently this issue is already known in several places: https://github.com/gentoo-perl/g-cpan/issues/6 https://rt.cpan.org/Public/Bug/Display.html?id=86171 I'll attach a patch.
Created attachment 387114 [details, diff] Fix warnings I'm quoting the header of that patch file. Avoid warnings on perl 5.20. "Possible precedence issue with control flow operator at Shell/EnvImporter/Result.pm line 88" This one is due to the fact that "return ..." binds more strongly than "and", so the function would simply "return $self->shell_status == 0", disregarding $self->command_status and $self->env_status. Changing "and" to "&&" solves this issue. "Use of uninitialized value $_[1] in read at IO/Handle.pm" This is because we don't initialize the hash "%buf" into which we read. Initializing the relevant keys with the empty string solves this issue. As a drive-by fix, we change the pipe handling so that the "last" command breaks the "while" loop, not the inner "foreach" loop.
Good work! But seems like the patch should be passed to upstream.
Can you please make a PR at https://github.com/gentoo-perl/g-cpan ?
(In reply to Sergiy Borodych from comment #2) > But seems like the patch should be passed to upstream. I agree, and just posted https://rt.cpan.org/Public/Bug/Display.html?id=86171#txn-1422747 notifying devs of this issue. (In reply to Vladimir Smirnov from comment #3) > Can you please make a PR at https://github.com/gentoo-perl/g-cpan ? The patch is against EnvImporter, not g-cpan. But I did comment on the existing https://github.com/gentoo-perl/g-cpan/issues/6 so g-cpan devs should become aware of this as well.
Since there is absolutely no motion upstream, I've added the first two chunks of the patch to dev-perl/Shell-EnvImporter-1.70.0-r2 (Sorry I dont do drive-by fixes. :)