I just accidentally attempted to put a DrWatson project into my registry and spent a while figuring out why it wouldn't work. The stated error is that check_version! doesn't work on nothing (see below). That makes sense because a project isn't a package, and so doesn't have a version number. It doesn't make sense to put a non-package into a registry so this should fail, but I would prefer a better error message so that no one wastes the half hour I just wasted.
My suggestion is that when the UUID is loaded, if it's nothing immediately error with the message Project.toml has no UUID. Is $(package_name) a package? This makes sense to me because all packages need UUIDs.
I'm happy to make the PR this weekend.
julia> register("./NeonateTriCorr", registry = "SmithThesisRegistry")
┌ Info: Registering package
│ package_path = "/home/graham/git/NeonateTriCorr"
│ registry_path = "/home/graham/.julia/registries/SmithThesisRegistry"
│ package_repo = "https://github.com/grahamas/NeonateTriCorr.git"
│ uuid = nothing
│ version = nothing
│ tree_hash = "acebe5e97e155b073082cd8e6939ba74dc50e4c0"
└ subdir = ""
HEAD is now at 1601a1b New package: TriCorrApplications v0.2.0
Removing N/NeonateTriCorr/
Already on 'main'
Your branch is up to date with 'origin/main'.
ERROR: MethodError: no method matching check_version!(::Nothing, ::Vector{VersionNumber}, ::RegistryTools.ReturnStatus)
Closest candidates are:
check_version!(::VersionNumber, ::Vector{VersionNumber}, ::RegistryTools.ReturnStatus) at ~/.julia/packages/RegistryTools/Epat9/src/register.jl:183
Stacktrace:
[1] check_versions!(pkg::Pkg.Types.Project, versions_data::Dict{String, Any}, status::RegistryTools.ReturnStatus)
@ RegistryTools ~/.julia/packages/RegistryTools/Epat9/src/register.jl:371
[2] check_and_update_registry_files(pkg::Pkg.Types.Project, package_repo::String, tree_hash::SubString{String}, registry_path::String, registry_deps_paths::Vector{String}, status::RegistryTools.ReturnStatus; subdir::String)
@ RegistryTools ~/.julia/packages/RegistryTools/Epat9/src/register.jl:575
[3] do_register(package::String, registry::String; commit::Bool, push::Bool, branch::Nothing, repo::Nothing, ignore_reregistration::Bool, gitconfig::Dict{Any, Any}, create_gitlab_mr::Bool)
@ LocalRegistry ~/.julia/packages/LocalRegistry/I8u9h/src/LocalRegistry.jl:247
[4] do_register
@ ~/.julia/packages/LocalRegistry/I8u9h/src/LocalRegistry.jl:156 [inlined]
[5] #register#2
@ ~/.julia/packages/LocalRegistry/I8u9h/src/LocalRegistry.jl:149 [inlined]
[6] top-level scope
@ REPL[6]:1
I just accidentally attempted to put a DrWatson project into my registry and spent a while figuring out why it wouldn't work. The stated error is that
check_version!
doesn't work onnothing
(see below). That makes sense because a project isn't a package, and so doesn't have a version number. It doesn't make sense to put a non-package into a registry so this should fail, but I would prefer a better error message so that no one wastes the half hour I just wasted.My suggestion is that when the UUID is loaded, if it's
nothing
immediately error with the messageProject.toml has no UUID. Is $(package_name) a package?
This makes sense to me because all packages need UUIDs.I'm happy to make the PR this weekend.