Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion src/Operations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1594,7 +1594,24 @@ function check_registered(registries::Vector{Registry.RegistryInstance}, pkgs::V
end
pkg = is_all_registered(registries, pkgs)
if pkg isa PackageSpec
pkgerror("expected package $(err_rep(pkg)) to be registered")
msg = "expected package $(err_rep(pkg)) to be registered"
# check if the name exists in the registry with a different uuid
if pkg.name !== nothing
reg_uuid = Pair{String, Vector{UUID}}[]
for reg in registries
uuids = Registry.uuids_from_name(reg, pkg.name)
if !isempty(uuids)
push!(reg_uuid, reg.name => uuids)
end
end
if !isempty(reg_uuid)
msg *= "\n You may have provided the wrong UUID for package $(pkg.name).\n Found the following UUIDs for that name:"
for (reg, uuids) in reg_uuid
msg *= "\n - $(join(uuids, ", ")) from registry: $reg"
end
end
end
pkgerror(msg)
end
return nothing
end
Expand Down
6 changes: 3 additions & 3 deletions test/new.jl
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,7 @@ end
isolate(loaded_depot=true) do; mktempdir() do tempdir
package_path = copy_test_package(tempdir, "UnregisteredUUID")
Pkg.activate(package_path)
@test_throws PkgError("expected package `Example [142fd7e7]` to be registered") Pkg.add("JSON")
@test_throws PkgError Pkg.add("JSON")
end end
# empty git repo (no commits)
isolate(loaded_depot=true) do; mktempdir() do tempdir
Expand Down Expand Up @@ -1536,7 +1536,7 @@ end
isolate(loaded_depot=true) do; mktempdir() do tempdir
package_path = copy_test_package(tempdir, "UnregisteredUUID")
Pkg.activate(package_path)
@test_throws PkgError("expected package `Example [142fd7e7]` to be registered") Pkg.update()
@test_throws PkgError Pkg.update()
end end
end

Expand Down Expand Up @@ -1714,7 +1714,7 @@ end
isolate(loaded_depot=true) do; mktempdir() do tempdir
package_path = copy_test_package(tempdir, "UnregisteredUUID")
Pkg.activate(package_path)
@test_throws PkgError("expected package `Example [142fd7e7]` to be registered") Pkg.update()
@test_throws PkgError Pkg.update()
end end
# package does not exist in the manifest
isolate(loaded_depot=true) do
Expand Down
12 changes: 12 additions & 0 deletions test/pkg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,18 @@ temp_pkg_dir() do project_path

@testset "package with wrong UUID" begin
@test_throws PkgError Pkg.add(PackageSpec(TEST_PKG.name, UUID(UInt128(1))))
@testset "package with wrong UUID but correct name" begin
try
Pkg.add(PackageSpec(name="Example", uuid=UUID(UInt128(2))))
catch e
@test e isa PkgError
errstr = sprint(showerror, e)
@test occursin("expected package `Example [00000000]` to be registered", errstr)
@test occursin("You may have provided the wrong UUID for package Example.", errstr)
@test occursin("Found the following UUIDs for that name:", errstr)
@test occursin("- 7876af07-990d-54b4-ab0e-23690620f79a from registry: General", errstr)
end
end
# Missing uuid
@test_throws PkgError Pkg.add(PackageSpec(uuid = uuid4()))
end
Expand Down