Skip to content

Commit 8e7396d

Browse files
author
KristofferC
committed
fix missing uuid check on extension when finding the location of an extension
in stacked environments with name collisions of extensions this could compute the path for the wrong extension
1 parent 3bfb382 commit 8e7396d

File tree

2 files changed

+19
-8
lines changed

2 files changed

+19
-8
lines changed

base/loading.jl

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -694,7 +694,7 @@ function manifest_uuid_path(env::String, pkg::PkgId)::Union{Nothing,String,Missi
694694
# if `pkg` matches the project, return the project itself
695695
return project_file_path(project_file, pkg.name)
696696
end
697-
mby_ext = project_file_ext_path(project_file, pkg.name)
697+
mby_ext = project_file_ext_path(project_file, pkg)
698698
mby_ext === nothing || return mby_ext
699699
# look for manifest file and `where` stanza
700700
return explicit_manifest_uuid_path(project_file, pkg)
@@ -709,7 +709,7 @@ function manifest_uuid_path(env::String, pkg::PkgId)::Union{Nothing,String,Missi
709709
if parent_project_file !== nothing
710710
parentproj = project_file_name_uuid(parent_project_file, parentid.name)
711711
if parentproj == parentid
712-
mby_ext = project_file_ext_path(parent_project_file, pkg.name)
712+
mby_ext = project_file_ext_path(parent_project_file, pkg)
713713
mby_ext === nothing || return mby_ext
714714
end
715715
end
@@ -725,13 +725,13 @@ function find_ext_path(project_path::String, extname::String)
725725
return joinpath(project_path, "ext", extname * ".jl")
726726
end
727727

728-
function project_file_ext_path(project_file::String, name::String)
728+
function project_file_ext_path(project_file::String, ext::PkgId)
729729
d = parsed_toml(project_file)
730730
p = dirname(project_file)
731731
exts = get(d, "extensions", nothing)::Union{Dict{String, Any}, Nothing}
732732
if exts !== nothing
733-
if name in keys(exts)
734-
return find_ext_path(p, name)
733+
if ext.name in keys(exts) && ext.uuid == uuid5(UUID(d["uuid"]::String), ext.name)
734+
return find_ext_path(p, ext.name)
735735
end
736736
end
737737
return nothing
@@ -834,9 +834,7 @@ function implicit_env_project_file_extension(dir::String, ext::PkgId)
834834
for pkg in readdir(dir; join=true)
835835
project_file = env_project_file(pkg)
836836
project_file isa String || continue
837-
proj = project_file_name_uuid(project_file, "")
838-
uuid5(proj.uuid, ext.name) == ext.uuid || continue
839-
path = project_file_ext_path(project_file, ext.name)
837+
path = project_file_ext_path(project_file, ext)
840838
if path !== nothing
841839
return path, project_file
842840
end

test/loading.jl

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1630,3 +1630,16 @@ end
16301630
copy!(LOAD_PATH, old_load_path)
16311631
end
16321632
end
1633+
1634+
@testset "extension path computation name collision" begin
1635+
old_load_path = copy(LOAD_PATH)
1636+
try
1637+
empty!(LOAD_PATH)
1638+
push!(LOAD_PATH, joinpath(@__DIR__, "project", "Extensions", "ExtNameCollision_A"))
1639+
push!(LOAD_PATH, joinpath(@__DIR__, "project", "Extensions", "ExtNameCollision_B"))
1640+
ext_B = Base.PkgId(Base.uuid5(Base.identify_package("ExtNameCollision_B").uuid, "REPLExt"), "REPLExt")
1641+
@test Base.locate_package(ext_B) == joinpath(@__DIR__, "project", "Extensions", "ExtNameCollision_B", "ext", "REPLExt.jl")
1642+
finally
1643+
copy!(LOAD_PATH, old_load_path)
1644+
end
1645+
end

0 commit comments

Comments
 (0)