-
-
Notifications
You must be signed in to change notification settings - Fork 270
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor: do not use double constructor for PackageSpec #2477
Conversation
Could the Line 146 in 9cf608c
|
There is something weird going on with the artifacts tests. It was giving some bad input to |
Perhaps @staticfloat (or anyone who knows those tests) could take a quick look. I'm almost certain it was just a matter of |
@@ -1,5 +1,5 @@ | |||
name = "ArtifactOverrideLoading" | |||
uuid = "9f5278ee-142d-5d9a-9723-c4aebaa272e1" | |||
uuid = "7b879065-7f74-5fa4-bdd5-9b7a15df8941" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did you need to change the UUID here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed it to the value of aol_uuid
because that was the value explicitly given here:
Line 641 in f073140
uuid=aol_uuid, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
huh, why wasn't this erroring before?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a misuse of the API here. API calls were supposed to be made with Pkg.PackageSpec
, not Pkg.Types.PackageSpec
. This is needlessly confusing, which is why this PR removes the second constructor.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, I'm specifically interested in why this having the wrong UUID didn't cause an issue before.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because Pkg.PackageSpec
did some pre-processing, which was circumvented by using Pkg.Types.PackageSpec
. In particular, Pkg.PackageSpec
automatically sets repo.source
, while Pkg.Types.PackageSpec
does not. So the package was in some undefined state which just happened to appear like it was tracking a path when it was written to the manifest.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So it seems like the intention was that they were supposed to be the same UUID? That is the only thing I was not sure of.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, they definitely should have matched
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, thanks. I think this slight adjustment was all that was necessary
add_this_pkg() | ||
Pkg.add(Pkg.Types.PackageSpec( | ||
name="ArtifactInstallation", | ||
uuid=Base.UUID("02111abe-2050-1119-117e-b30112b5bdc4"), | ||
path=joinpath(project_path, "ArtifactInstallation"), | ||
path=path, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What were the errors you were seeing? I'm not sure why git_init_package()
would have any different behavior here from copy_test_package()
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for reviewing. Pkg.add
requires the package to be git version controlled because it always clones (it doesn't track the path directly like Pkg.develop
does).
It looks like this PR made a breaking change in the public API: On Julia 1.6.1: julia> import Pkg
julia> Pkg.PackageSpec(; name = "Example", uuid = "7876af07-990d-54b4-ab0e-23690620f79a")
PackageSpec(
name = Example
uuid = 7876af07-990d-54b4-ab0e-23690620f79a
version = *
) On Julia master: julia> import Pkg
julia> Pkg.PackageSpec(; name = "Example", uuid = "7876af07-990d-54b4-ab0e-23690620f79a")
ERROR: MethodError: Cannot `convert` an object of type String to an object of type Base.UUID
Closest candidates are:
convert(::Type{T}, ::T) where T at essentials.jl:228
Base.UUID(::AbstractString) at uuid.jl:87
Base.UUID(::Any) at uuid.jl:9
Stacktrace:
[1] convert(#unused#::Type{Union{Nothing, Base.UUID}}, x::String)
@ Base ./some.jl:36
[2] Pkg.Types.PackageSpec(name::String, uuid::String, version::Pkg.Versions.VersionSpec, tree_hash::Nothing, repo::Pkg.Types.GitRepo, path::Nothing, pinned::Bool, url::Nothing, rev::Nothing, subdir::Nothing)
@ Pkg.Types ~/dev/repos/JuliaLang/julia/usr/share/julia/stdlib/v1.7/Pkg/src/Types.jl:92
[3] Pkg.Types.PackageSpec(; name::String, uuid::String, version::Pkg.Versions.VersionSpec, tree_hash::Nothing, repo::Pkg.Types.GitRepo, path::Nothing, pinned::Bool, url::Nothing, rev::Nothing, subdir::Nothing)
@ Pkg.Types ./util.jl:471
[4] top-level scope
@ REPL[1]:1 Is this easy to fix? Or should we revert this PR? |
Fix #2282
I admit that messing with the constructor was a thoroughly terrible idea. The check could be circumvented anyway by manually setting the fields after the constructor call. The checking should be done inside the API.