PackageCompiler - "has no known versions!"


#1

I am having difficulties with compiling my own package.

I have my own package “Foo” functional and registered.

(v1.0) pkg> st
    Status `C:\Users\m136270\.julia\environments\v1.0\Project.toml`
  [537997a7] AbstractPlotting v0.9.4
...
  [dd5dd2d0] Foo v0.1.0 [`N:\My Documents\Programming\Julia\Modules\Foo`]
...

using Foo runs without problems.

However, compile_package fails with a strange error:

julia> compile_package("Foo")
[ Info: activating new environment at C:\Users\m136270\.julia\packages\PackageCompiler\SGFCk\packages\Reflectivity\Project.toml.
  Updating registry at `C:\Users\m136270\.julia\registries\General`
  Updating git-repo `https://github.com/JuliaRegistries/General.git`
 Resolving package versions...
ERROR: LoadError: Unsatisfiable requirements detected for package Reflectivity [dd5dd2d0]:
 Reflectivity [dd5dd2d0] log:
 ├─Reflectivity [dd5dd2d0] has no known versions!
 └─restricted to versions * by an explicit requirement - no versions left

So I understand, that the newly created environment somehow fails to find my package. Maybe I am missing something?

Thanks in advance for any hint!


#2

I did find the root cause :slight_smile:
The point is that snooping.jl generates a file run_julia_code.jl with

using Pkg, PackageCompiler
Pkg.activate("C:\\Users\\m136270\\.julia\\dev\\PackageCompiler\\packages\\Foo\\Project.toml")
Pkg.instantiate()
# let's wrap the snoop file in a try catch...
# This way we still do some snooping even if there is an error in the tests!
try
    include("N:\\My Documents\\Programming\\Julia\\Modules\\Foo\\test\\runtests.jl")
catch e
    @warn("Snoop file errored. Precompile statements were recorded untill error!", exception = e)
end

Pkg.instantiate fails because “Foo” is not known to the new environment.
My current workaround is to add

Pkg.develop(PackageSpec(path=$(repr(normpath(snoopfile * "\\..\\..")))))

before Pkg.instantiate() which works for the case that the snoopfile is located in the default test directory, e.g. runtests.jl

If I find a more elegant solution, I will leave a message here.


#3

I think I just figured out the problem… I’m drafting a solution right now!


#4

Great! :+1:


#5

Ok, this PR solves one problem: https://github.com/JuliaLang/PackageCompiler.jl/pull/179
I’m writing some tests right now, to verify that it also solves your problem.
Let me know if it already works for you :slight_smile:
Btw, I suggest using compile_incremental(:Foo)!


#6

Hi Simon,
thanks for your quick reply. Unfortunately, this PR doesn’t fix my problem, because Pkg.instantiate() still doesn’t know my local package.
I also realised earlier that compile_package or compile_incremental are not aware of my normal environment, e.g. the standard ImageMagick.jl is taken instead of master, although in my standard environment I have done add ImageMagick#master. Maybe, both things have the same origin?
Unfortunately, I am not enough low-level Julian to come up with a general solution.


#7

Yeah sorry, it still wasn’t not solved :wink: But I think I got it now! I’ll push when local tests pass!


#8

pushed the fix to the same branch!


#9

Works like a charm … and it solves the problem that a package working with your local setup can be compiled!
You are my hero :wink:


#10

Btw, today I tried to get compile_incremental(:Makie) running.
The process succeeds and writes a sys.dll, I can successfully call julia -Jsys.dll, and do a very quick using Makie :slight_smile:
Alas, scene=Scene() answers on the console and doesn’t open up a Makie window.

Any proposal?

P.S.: I added some lines to snooping.jl iin order to maintain the same versions of the packages:

command *= """
  empty!(Base.LOAD_PATH)
  # Take LOAD_PATH from parent process
  append!(Base.LOAD_PATH, $(repr(Base.LOAD_PATH)))
  sourceManifest = joinpath(dirname($(repr(Base.active_project()))), "Manifest.toml")
  Pkg.activate($(repr(tomlpath))) 
  targetManifest = joinpath(dirname(Base.active_project()), "Manifest.toml")
                         
  Pkg.instantiate()
  cp(sourceManifest, targetManifest; force = true)
  Pkg.resolve()
"""
@info command


#11

Try AbstractPlotting.__init__()


#12

:grinning: