Developing packages that are already in the loaded sysimage

How can I develop a package, MyPkg, when a sysimage that contains MyPkg (among others) is already loaded?
So far, the only thing that’s worked for me is locally changing the UUID and name of the development version of the package entirely. There’s gotta be an easier way to do this (maybe some Revise-wizardry?)

EDIT: Oh, I misunderstood the question. I’ll leave this here anyway

using Pkg
using PackageCompiler
Pkg.activate("/path/to/MyPkg")
create_sysimage(; sysimage_path="MyPkg.so")

and then when you want to use it

$ julia --sysimage /path/to/MyPkg.so

Updating the UUID is enough, the name can stay the same.

If you update the UUID it should “just work” with Revise, no wizardry needed.

1 Like

Updating the UUID is enough, the name can stay the same.

That doesn’t seem to work for me, for whatever reason, on Julia 1.6.5.

Here’s the error I get when I update the UUID and try to load the module with the sysimage loaded (with JSON3 as MyPkg) -

julia> using JSON3
WARNING: using JSON3.JSON3 in module Main conflicts with an existing identifier.
ERROR: importing JSON3 into Main conflicts with an existing identifier

I think you have to describe more what you are actually doing then. JSON3 is not in the (default) sysimage, so you shouldn’t have to do any UUID-trickery at all.

Let me elaborate.
I’m creating a custom sysimage, that has a few packages, which includes JSON3.

julia> create_sysimage(["JSON3", ...]; sysimage_path = "sysimage_test.so")

Now, I also want to actively develop a local copy of JSON3 and run the tests with the latest changes that I have, while having this custom sysimage loaded
julia --project=JSON3 -J sysimage_test.so -e 'using Pkg; Pkg.test()'

When I change the UUID of my local copy of JSON3 and try to using JSON3, I get the above error.

I hope this explanation makes things more clear.

Here’s what finally worked for me -

  • Change the UUID of the local copy of package (JSON3)
  • Import the local copy (as opposed to the copy in the sysimage) the following way -
    import JSON3 as JSON3LocalCopy.
    This will allow you to use the latest version of the package you’re developing, even if the said package is already present within the sysimage loaded.
2 Likes