Skip to content

Commit 14eeb39

Browse files
staticfloatIanButterworth
authored andcommitted
Fix is_instantiated() (#2338)
Previously, `is_instantiated()` would only check for the presence of dependencies, which caused artifacts belonging to the top-level project itself to be missed in its check. This rectifies that oversight. (cherry picked from commit e54b83c)
1 parent 21892b8 commit 14eeb39

File tree

3 files changed

+16
-7
lines changed

3 files changed

+16
-7
lines changed

src/API.jl

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1296,9 +1296,7 @@ function instantiate(ctx::Context; manifest::Union{Bool, Nothing}=nothing,
12961296
" Otherwise, remove `$name` with `Pkg.rm(\"$name\")`.",
12971297
" Finally, run `Pkg.instantiate()` again.")
12981298
end
1299-
# TODO: seems to be a bug in is_instantiated on the line below so we have to download
1300-
# artifacts here even though we do the same at the end of this function
1301-
Operations.download_artifacts(ctx, [dirname(ctx.env.manifest_file)]; platform=platform, verbose=verbose)
1299+
13021300
# check if all source code and artifacts are downloaded to exit early
13031301
if Operations.is_instantiated(ctx)
13041302
allow_autoprecomp && Pkg._auto_precompile(ctx)
@@ -1351,10 +1349,14 @@ function instantiate(ctx::Context; manifest::Union{Bool, Nothing}=nothing,
13511349

13521350
# Install all packages
13531351
new_apply = Operations.download_source(ctx, pkgs)
1354-
# Install all artifacts
1355-
Operations.download_artifacts(ctx, pkgs; platform=platform, verbose=verbose)
1352+
# Install artifacts for deps and artifacts for current package, if applicable
1353+
art_pkgs = copy(pkgs)
1354+
if ctx.env.pkg !== nothing
1355+
push!(art_pkgs, ctx.env.pkg)
1356+
end
1357+
Operations.download_artifacts(ctx, art_pkgs; platform, verbose)
13561358
# Run build scripts
1357-
Operations.build_versions(ctx, union(UUID[pkg.uuid for pkg in new_apply], new_git); verbose=verbose)
1359+
Operations.build_versions(ctx, union(UUID[pkg.uuid for pkg in new_apply], new_git); verbose)
13581360

13591361
allow_autoprecomp && Pkg._auto_precompile(ctx; kwargs...)
13601362
end

src/Operations.jl

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,13 @@ end
114114
function is_instantiated(ctx::Context)::Bool
115115
# Load everything
116116
pkgs = load_all_deps(ctx)
117-
# Make sure all paths exist
117+
# If the top-level project is a package, ensure it is instantiated as well
118+
if ctx.env.pkg !== nothing
119+
push!(pkgs, Types.PackageSpec(
120+
name=ctx.env.pkg.name, uuid=ctx.env.pkg.uuid, version=ctx.env.pkg.version, path=dirname(ctx.env.project_file)
121+
))
122+
end
123+
# Make sure all paths/artifacts exist
118124
return all(pkg -> is_package_downloaded(ctx, pkg), pkgs)
119125
end
120126

src/Types.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,7 @@ function EnvCache(env::Union{Nothing,String}=nothing)
270270
name = project.name,
271271
uuid = project.uuid,
272272
version = something(project.version, VersionNumber("0.0")),
273+
path = project_dir,
273274
)
274275
else
275276
project_package = nothing

0 commit comments

Comments
 (0)