in reply to CPAN and "Weak references"

Weak references are not implemented in the version of perl

Usually, this has to do with the XS component of Scalar::Util not being found (in which case weaken() is not available):

$ perl -MScalar::Util=weaken -e'weaken(\my $var)' $ sudo mv /usr/lib/perl5/5.8.8/x86_64-linux-thread-multi/auto/List/Uti +l/Util.so /usr/lib/perl5/5.8.8/x86_64-linux-thread-multi/auto/List/Ut +il/Util.so_hide $ perl -MScalar::Util=weaken -e'weaken(\my $var)' Weak references are not implemented in the version of perl at -e line +0 BEGIN failed--compilation aborted.

Replies are listed 'Best First'.
Re^2: CPAN and "Weak references"
by arthurg (Acolyte) on Dec 07, 2009 at 21:18 UTC
    Thanks Almut, but that doesn't seem to be the case; auto/List/Util/Util.so is in an element of @INC:
    $ perl -MScalar::Util=weaken -e'weaken(\my $var)' Weak references are not implemented in the version of perl at -e line +0 BEGIN failed--compilation aborted.
    $ locate Util.so /usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/auto/List/Util/Util.s +o /usr/lib64/perl5/vendor_perl/5.8.8/x86_64-linux-thread-multi/auto/APR/ +Util/Util.so /usr/lib64/perl5/vendor_perl/5.8.8/x86_64-linux-thread-multi/auto/Apac +he2/ConnectionUtil/ConnectionUtil.so /usr/lib64/perl5/vendor_perl/5.8.8/x86_64-linux-thread-multi/auto/Apac +he2/RequestUtil/RequestUtil.so /usr/lib64/perl5/vendor_perl/5.8.8/x86_64-linux-thread-multi/auto/Apac +he2/ServerUtil/ServerUtil.so /usr/lib64/perl5/vendor_perl/5.8.8/x86_64-linux-thread-multi/auto/Apac +he2/Util/Util.so /usr/lib64/perl5/vendor_perl/5.8.8/x86_64-linux-thread-multi/auto/ModP +erl/Util/Util.so
    $ perl -e 'print join( "\n", @INC), "\n";' /usr/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi /usr/lib/perl5/site_perl/5.8.8 /usr/lib/perl5/site_perl /usr/lib64/perl5/vendor_perl/5.8.8/x86_64-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.8 /usr/lib/perl5/vendor_perl /usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi /usr/lib/perl5/5.8.8 .

      You might additionally want to check whether Util.so is in fact being loaded:

      $ strace -efile perl -MScalar::Util=weaken -e'weaken(\my $var)' 2>&1 | + grep Util\.so

      With a working installation, the results should look something like

      stat("/usr/lib/perl5/5.8.8/auto/List/Util/Util.so", 0x63b140) = -1 ENO +ENT (No such file or directory) stat("/usr/lib/perl5/5.8.8/x86_64-linux-thread-multi/auto/List/Util/Ut +il.so", {st_mode=S_IFREG|0555, st_size=40616, ...}) = 0 open("/usr/lib/perl5/5.8.8/x86_64-linux-thread-multi/auto/List/Util/Ut +il.so", O_RDONLY) = 6

      Otherwise, you'd get stat()s with ENOENT only (several dozens, typically), or maybe an attempted open() with EACCES (Permission denied), but no successful open()

        Fantastic diagnosis almut and Corion! Reinstalling Scalar::Util fixed the problem, stopping the "Weak references" error, and rendering CPAN operable. You made my day!

        However, I remain perplexed. I don't understand why this problem occurred or how you diagnosed it.

        WRT 'why', unfortunately, I don't have a logging filesystem that could show all updates, and even if I did, I don't know how do identify the update(s) that caused this problem. My differential backup shows a change in /usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/auto/List/Util/Util.so on 120209, but the problem didn't surface until 12/6/9. I surmise that it didn't surface until the modified file was loaded, but I really don't know.

        WRT 'how', you say "your Perl did not compile the XS component of Scalar::Util, and your search seems to confirm that for me", but 'locate' found /usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/auto/List/Util/Util.so installed (although I should have used 'ls -l' to check its current status) so I didn't see any indication of Scalar::Util installation trouble other than the "Weak references" error.

        In any case, thanks again monks.

      But List::Util (to which List/Util/Util.so belongs) is a different module than Scalar::Util. Most likely, in your upgrade, your Perl did not compile the XS component of Scalar::Util, and your search seems to confirm that for me. So, reinstall Scalar::Util and make sure you have a matching C compiler for the Perl you're using available, so the XS component gets compiled.

        But List::Util (to which List/Util/Util.so belongs) is a different module than Scalar::Util.

        List/Util/Util.so does in fact belong to Scalar::Util (the module is somewhat peculiar in that respect).

        $ nm -D /usr/lib/perl5/5.8.8/x86_64-linux-thread-multi/auto/List/Util/ +Util.so | grep weaken U Perl_sv_rvweaken 0000000000003f70 T XS_Scalar__Util_weaken