Discussion:
how to investigate "Attempt to reload Readonly/XS.pm aborted"
(too old to reply)
Normand
2014-04-29 16:56:02 UTC
Permalink
Hi there,
I have an error as detailed in the attached tst1.t perl script where the "use Readonly::XS;" line is failing.I tried to use perl -d debug mode but not working as use line is part of the compile section.
I do not know how to investigate such a problem, so I would appreciate any suggestion.

# ===============================================
# $perl tst1.t
# Attempt to reload Readonly/XS.pm aborted.
# Compilation failed in require at tst1.t line 26.
# BEGIN failed--compilation aborted at tst1.t line 26.
# ===============================================
--
Michel Normand
Reini Urban
2014-04-30 17:23:20 UTC
Permalink
This has nothing to do with perl-xs, you'd need to read the module
documentation first.
perldoc Readonly
perldoc Readonly::XS

perl -MReadonly::XS -e0
Readonly::XS is not a standalone module. You should not use it
directly. at Readonly/XS.pm line 34.
Matthew Horsfall (alh)
2014-05-02 12:54:26 UTC
Permalink
Post by Normand
Hi there,
I have an error as detailed in the attached tst1.t perl script where the
"use Readonly::XS;" line is failing.I tried to use perl -d debug mode but
not working as use line is part of the compile section.
I do not know how to investigate such a problem, so I would appreciate any suggestion.
Normand,

One trick you can use here is to eval the "use Readonly; use
Readonly::XS" so that it happens at runtime rather than compile time.
Alternatively, you can use "require", so it now looks like this:

#!/usr/bin/perl

use strict;
use warnings;

require Readonly;
require Readonly::XS;

And if we run it with Devel::Trace, we now get some useful output
which pinpoints the real error:

$ perl -d:Trace tst1.txt
[ LOTS OF OUTPUT ]
...
Post by Normand
/usr/local/lib/perl/5.14.2/Readonly/XS.pm:29: if
($MAGIC_COOKIE ne "Do NOT use or require Readonly::XS unless you're
me.")
Post by Normand
/usr/local/lib/perl/5.14.2/Readonly/XS.pm:31: require Carp;
Carp::croak("Readonly::XS is not a standalone module. You should not
use it directly.");
---
[ LOTS MORE OUTPUT ]

So Readonly.pm is doing "eval 'use Readonly::XS';", which croaks, and
leaves things in a weird state so when tst1.txt comes along and says
"use Readonly::XS", you get the unhelpful error message. (Perhaps a
bug in Perl, I think I'll bring this up with Perl5 Porters).

Hope that helps.

-- Matthew Horsfall (alh)

Loading...