PackageCompiler.jl icon indicating copy to clipboard operation
PackageCompiler.jl copied to clipboard

`create_sysimage(; project)` does not support shared environments

Open omus opened this issue 1 year ago • 1 comments

Attempting to use a shared environment (e.g. julia --project=@shared) does not work when using the @ syntax when calling create_sysimage with the project keyword. For example:

julia --project=@sysimage -e 'using Pkg; Pkg.add("Example")'
julia -e '
    using Pkg
    Pkg.add(PackageSpec(name="PackageCompiler", version="2"))
    using PackageCompiler
    create_sysimage(; project="@sysimage", sysimage_path="sysimage.so")'

Which results in the error:

ERROR: could not find project at "@sysimage"
Stacktrace:
 [1] error(s::String)
   @ Base ./error.jl:35
 [2] create_pkg_context(project::String)
   @ PackageCompiler ~/.julia/packages/PackageCompiler/UbaS4/src/PackageCompiler.jl:71
 [3] create_sysimage(packages::Nothing; sysimage_path::String, project::String, precompile_execution_file::Vector{String}, precompile_statements_file::Vector{String}, incremental::Bool, filter_stdlibs::Bool, cpu_target::String, script::Nothing, sysimage_build_args::Cmd, include_transitive_dependencies::Bool, base_sysimage::Nothing, julia_init_c_file::Nothing, julia_init_h_file::Nothing, version::Nothing, soname::Nothing, compat_level::String, extra_precompiles::String, import_into_main::Bool)
   @ PackageCompiler ~/.julia/packages/PackageCompiler/UbaS4/src/PackageCompiler.jl:560
 [4] create_sysimage
   @ ~/.julia/packages/PackageCompiler/UbaS4/src/PackageCompiler.jl:527 [inlined]
 [5] top-level scope
   @ none:5

This can be worked around by specifying the full path to the shared environment (e.g. convert project="@sysimage" to project=joinpath(first(DEPOT_PATH), "environments", "sysimage"))

omus avatar Dec 21 '24 05:12 omus

Discovered while working on: https://github.com/JuliaTime/TimeZones.jl/pull/479

omus avatar Dec 21 '24 05:12 omus