Skip to content

Commit

Permalink
Fix lacking subdir information when altering packages (#3597)
Browse files Browse the repository at this point in the history
If a package we're altering is already in the manifest, we try to load
some information from the manifest, but we forgot to load `subdir` in
these two cases.  Add tests to ensure that `add`ing or `dev`ing the same
package twice in the same environment does not error.

This fixes #3391.
  • Loading branch information
staticfloat authored Aug 21, 2023
1 parent 051ab5b commit 2c37a59
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/Types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -635,6 +635,7 @@ function handle_repo_develop!(ctx::Context, pkg::PackageSpec, shared::Bool)
entry = manifest_info(ctx.env.manifest, uuid)
if entry !== nothing
pkg.repo.source = entry.repo.source
pkg.repo.subdir = entry.repo.subdir
end
end
end
Expand Down Expand Up @@ -738,8 +739,9 @@ function handle_repo_add!(ctx::Context, pkg::PackageSpec)
manifest_resolve!(ctx.env.manifest, [pkg]; force=true)
if isresolved(pkg)
entry = manifest_info(ctx.env.manifest, pkg.uuid)
if entry !== nothing && entry.repo.source !== nothing # reuse source in manifest
if entry !== nothing
pkg.repo.source = entry.repo.source
pkg.repo.subdir = entry.repo.subdir
end
end
if pkg.repo.source === nothing
Expand Down
8 changes: 8 additions & 0 deletions test/subdir.jl
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,10 @@ end
@test isinstalled("Package")
@test !isinstalled("Dep")
@test isinstalled(dep)

# Test that adding a second time doesn't error (#3391)
pkg"add Package#master"
@test isinstalled("Package")
pkg"rm Package"

pkg"add Dep#master"
Expand All @@ -204,6 +208,10 @@ end
@test isinstalled("Package")
@test !isinstalled("Dep")
@test isinstalled(dep)

# Test developing twice (#3391)
pkg"develop Package"
@test isinstalled("Package")
pkg"rm Package"

pkg"develop Dep"
Expand Down

0 comments on commit 2c37a59

Please sign in to comment.