In my project, I have a couple of sub-projects:
[workspace]
projects = ["examples", "examples_3d", "docs", "test"]
I am trying to write an install script that instantiates and precompiles the main project and all sub-projects. It seems to work with Julia 1.12, but not with Julia 1.11. Is there a way to make it work with Julia 1.11?
I tried:
- First to copy
Manifest-v1.11.toml.defaulttoManifest-v1.11.toml(the de9.fault manifest is from Git and represents the last known good set of package versions - Instantiate the project
julia --project -e '
using Pkg
try
Pkg.instantiate()
catch e
@warn "Pkg.instantiate() failed, attempting fresh resolve..." exception=e
proj_dir = dirname(Base.active_project())
# Remove all manifest files to force a clean resolve
for f in readdir(proj_dir)
if startswith(f, "Manifest") && endswith(f, ".toml") && !endswith(f, ".default")
rm(joinpath(proj_dir, f), force=true)
end
end
Pkg.resolve()
Pkg.instantiate()
end
'
- Precompile the main project:
julia --project -e 'using Pkg; Pkg.precompile()'
- Resolve sub-projects independently:
rm -f examples/Manifest*.toml test/Manifest*.toml examples_3d/Manifest*.toml
julia --project=examples -e 'using Pkg; Pkg.resolve(); Pkg.instantiate()'
echo "Precompiling examples project..."
julia --project=examples -e 'using Pkg; Pkg.precompile()'
julia --project=test -e 'using Pkg; Pkg.resolve(); Pkg.instantiate()'
echo "Precompiling test project..."
julia --project=test -e 'using Pkg; Pkg.precompile()'
julia --project=examples_3d -e 'using Pkg; Pkg.resolve(); Pkg.instantiate()'
echo "Precompiling examples_3d project..."
julia --project=examples_3d -e 'using Pkg; Pkg.precompile()'
While this somewhat works, it results in:
- the sub-projects not using the same package versions as the main project
- If I open any of the examples, it starts precompiling the packages again
Any idea how to fix these issues?
Observation:
- If I copy the main manifest into a subproject, activate the subproject, and run Pkg.resolve(), this often fails. Is this a bug in the Pkg package?
UPDATE:
I created an issue: Resolve does not find a solution · Issue #4623 · JuliaLang/Pkg.jl · GitHub