Skip to content

Commit 055f0e1

Browse files
KristofferCgamila-wisam
authored andcommitted
add manifest path to error messages when validating manifest (#4612)
1 parent 4a79ed0 commit 055f0e1

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

src/manifest.jl

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,8 @@ struct Stage1
147147
weakdeps::Union{Vector{String}, Dict{String, UUID}}
148148
end
149149

150-
normalize_deps(name, uuid, deps, manifest; isext = false) = deps
151-
function normalize_deps(name, uuid, deps::Vector{String}, manifest::Dict{String, Vector{Stage1}}; isext = false)
150+
normalize_deps(name, uuid, deps, manifest, manifest_path; isext = false) = deps
151+
function normalize_deps(name, uuid, deps::Vector{String}, manifest::Dict{String, Vector{Stage1}}, manifest_path; isext = false)
152152
if length(deps) != length(unique(deps))
153153
pkgerror("Duplicate entry in `$name=$uuid`'s `deps` field.")
154154
end
@@ -159,14 +159,14 @@ function normalize_deps(name, uuid, deps::Vector{String}, manifest::Dict{String,
159159
if infos === nothing
160160
pkgerror(
161161
"`$name=$uuid` depends on `$dep`, ",
162-
"but no such entry exists in the manifest."
162+
"but no such entry exists in the manifest at `$manifest_path`."
163163
)
164164
end
165165
end
166166
# should have used dict format instead of vector format
167167
if isnothing(infos) || length(infos) != 1
168168
pkgerror(
169-
"Invalid manifest format. ",
169+
"Invalid manifest format at `$manifest_path`. ",
170170
"`$name=$uuid`'s dependency on `$dep` is ambiguous."
171171
)
172172
end
@@ -175,13 +175,17 @@ function normalize_deps(name, uuid, deps::Vector{String}, manifest::Dict{String,
175175
return final
176176
end
177177

178-
function validate_manifest(julia_version::Union{Nothing, VersionNumber}, project_hash::Union{Nothing, SHA1}, manifest_format::VersionNumber, stage1::Dict{String, Vector{Stage1}}, other::Dict{String, Any}, registries::Dict{String, ManifestRegistryEntry})
178+
manifest_path_str(f_or_io::IO) = "streamed manifest"
179+
manifest_path_str(path::String) = path
180+
181+
function validate_manifest(julia_version::Union{Nothing, VersionNumber}, project_hash::Union{Nothing, SHA1}, manifest_format::VersionNumber, stage1::Dict{String, Vector{Stage1}}, other::Dict{String, Any}, registries::Dict{String, ManifestRegistryEntry}, f_or_io)
182+
manifest_path = manifest_path_str(f_or_io)
179183
# expand vector format deps
180184
for (name, infos) in stage1, info in infos
181-
info.entry.deps = normalize_deps(name, info.uuid, info.deps, stage1)
185+
info.entry.deps = normalize_deps(name, info.uuid, info.deps, stage1, manifest_path)
182186
end
183187
for (name, infos) in stage1, info in infos
184-
info.entry.weakdeps = normalize_deps(name, info.uuid, info.weakdeps, stage1; isext = true)
188+
info.entry.weakdeps = normalize_deps(name, info.uuid, info.weakdeps, stage1, manifest_path; isext = true)
185189
end
186190
# invariant: all dependencies are now normalized to Dict{String,UUID}
187191
deps = Dict{UUID, PackageEntry}()
@@ -197,13 +201,13 @@ function validate_manifest(julia_version::Union{Nothing, VersionNumber}, project
197201
if dep_entry === nothing
198202
pkgerror(
199203
"`$(entry.name)=$(entry_uuid)` depends on `$name=$uuid`, ",
200-
"but no such entry exists in the manifest."
204+
"but no such entry exists in the manifest at `$manifest_path`."
201205
)
202206
end
203207
if dep_entry.name != name
204208
pkgerror(
205209
"`$(entry.name)=$(entry_uuid)` depends on `$name=$uuid`, ",
206-
"but entry with UUID `$uuid` has name `$(dep_entry.name)`."
210+
"but entry with UUID `$uuid` has name `$(dep_entry.name)` in the manifest at `$manifest_path`."
207211
)
208212
end
209213
end
@@ -291,7 +295,7 @@ function Manifest(raw::Dict{String, Any}, f_or_io::Union{String, IO})::Manifest
291295
end
292296
other[k] = v
293297
end
294-
return validate_manifest(julia_version, project_hash, manifest_format, stage1, other, registries)
298+
return validate_manifest(julia_version, project_hash, manifest_format, stage1, other, registries, f_or_io)
295299
end
296300

297301
function read_manifest(f_or_io::Union{String, IO})

0 commit comments

Comments
 (0)