API version clash for parallel installations

I’ve got several parallel versions of Octave installed on my system (Ubuntu 18.04.5), which are

  • a version of the default branch, pulled from Mercurial in May 2020
  • the version tagged 6.3.0 of the stable branch from Mercurial

Running some of my scripts with the version 6.3.0 results in the following error:

error: API version api-v54+ found in .oct file function ‘fields2cell’
does not match the running Octave (API version api-v56)
this can lead to incorrect results or other failures
you can fix this problem by recompiling this .oct file

I googled around and found this bug, that is currently marked as fixed: GNU Octave - Bugs: bug #53627, build: oct files should not need... [Savannah]

My questions are:

  1. Is the “fixed” bug related to this at all? I’ve got to say that I don’t really understand the internal workings of installations and systems …
  2. Is there any good workaround for this? Would it help to deinstall the old version / reinstall the new version?
  3. How could I check for this error in the future? I only stumbled upon it by chance (running the optim-package’s lsqnonlin, which calls jaconbian_constants, which calls fields2cell), and I don’t know how many other functions would throw the same error

Yes, simply reinstall the package

pkg uninstall parallel
pkg   install parallel

And your problem is gone. To stay on the safe side, apply this to all your installed Octave packages at each change of your Octave version.

Some package do not have compiled code and do not need this procedure to continue working.

The reason you are seeing this message is that binaries might not be compatible between different versions of Octave.
Alternatively to what @siko1056 wrote, if you prefer to continue using both versions of Octave in parallel, you could redirect the folders that are used for installing and managing packages. E.g.:

pkg ('prefix', fullfile ('~', 'octave', version ()));
pkg ('local_list', fullfile ('~', 'octave_packages', version ()));

See also the documentation of pkg.

You could add those commands to your .octaverc file to “permanently” override the package installation directories.

Thank you both for the explanation! The faulty package in that case (fields2cell) wasn’t parallel but struct …
Reinstalling my packages fixed the error.