WithABeard has asked for the wisdom of the Perl Monks concerning the following question:

I get this weird error when using the JSON or JSON::XS module:

$ perl -MJSON -e ''

XS.c: loadable library and perl binaries are mismatched (got first handshake key 0xeb80080, needed 0xf380080)

And the same error for perl -MJSON::XS -e ''

perl -v This is perl 5, version 38, subversion 0 (v5.38.0) built for x86_64-li +nux-thread-multi ...

What could cause this, and what can I do to fix it?

  • Comment on Strange error when using JSON module "XS.c: loadable library and perl binaries are mismatched"
  • Select or Download Code

Replies are listed 'Best First'.
Re: Strange error when using JSON module "XS.c: loadable library and perl binaries are mismatched"
by Fletch (Bishop) on Nov 30, 2023 at 15:30 UTC

    Just for a bit more explanation: modules need to be built against the version of perl they're being used with to make sure the internals and other APIs used match up with each other. You should be able to use modules with the same major.minor irrespective of the patch level, but otherwise they're going to be incompatible. If you (say) have a personal library directory with local::lib that you built with a previous version and then upgrade (again, to a different major.minor) you should reinstall things as you say you did (and/or make a different directory for that version and install things there).

    The cake is a lie.
    The cake is a lie.
    The cake is a lie.

Re: Strange error when using JSON module "XS.c: loadable library and perl binaries are mismatched"
by WithABeard (Beadle) on Nov 30, 2023 at 07:58 UTC

    I seem to have solved it

    I had JSON and JSON::XS installed in my home dir, for some reason. So I installed cpanminus so that I could uninstall them: cpanm -U JSON and cpanm -U JSON::XS

    And now it works, since they are installed system wide as well