Skip to content

Commit a6f4a38

Browse files
timholyfredrikekre
authored andcommitted
Add test for #2302, closes #2302 (#2352)
Closes #2302 * Fix is_instantiated if top-level project-package already exist in the manifest. Co-authored-by: Fredrik Ekre <[email protected]> (cherry picked from commit 1f12cac)
1 parent 14eeb39 commit a6f4a38

File tree

2 files changed

+24
-3
lines changed

2 files changed

+24
-3
lines changed

src/Operations.jl

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,15 @@ function is_instantiated(ctx::Context)::Bool
116116
pkgs = load_all_deps(ctx)
117117
# If the top-level project is a package, ensure it is instantiated as well
118118
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-
))
119+
# Top-level project may already be in the manifest (cyclic deps)
120+
# so only add it if it isn't there
121+
idx = findfirst(x -> x.uuid == ctx.env.pkg.uuid, pkgs)
122+
if idx === nothing
123+
push!(pkgs, Types.PackageSpec(
124+
name=ctx.env.pkg.name, uuid=ctx.env.pkg.uuid, version=ctx.env.pkg.version,
125+
path=dirname(ctx.env.project_file)
126+
))
127+
end
122128
end
123129
# Make sure all paths/artifacts exist
124130
return all(pkg -> is_package_downloaded(ctx, pkg), pkgs)

test/new.jl

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2413,6 +2413,21 @@ end
24132413
Pkg.add(path="A")
24142414
end
24152415
end
2416+
# test #2302
2417+
isolate(loaded_depot=true) do
2418+
cd_tempdir() do dir
2419+
Pkg.generate("A")
2420+
Pkg.generate("B")
2421+
git_init_and_commit("B")
2422+
Pkg.develop(path="B")
2423+
Pkg.activate("A")
2424+
Pkg.add(path="B")
2425+
git_init_and_commit("A")
2426+
Pkg.activate("B")
2427+
# This shouldn't error even though A has a dependency on B
2428+
Pkg.add(path="A")
2429+
end
2430+
end
24162431
end
24172432

24182433
@testset "Offline mode" begin

0 commit comments

Comments
 (0)