I'm getting a TOML parsing error that I don't understand. This occurs when I add a particular package as a dependency and then resolve. The dependency loads and resolves fine on its own (when it's not used used as a dependency) so I don't think it's a problem with any .toml files belonging to the dependency. Nor does it seem to be a problem with the Project.toml file of the package including the dependency, I've checked the formatting and looked especially for newline issues. So I don't know where else to look. I might be able to understand this better by modifying TOML.jl, but "developing" the Pkg package seems a bit complex so I'm hoping someone might have an easy answer before I do that.
ERROR: Pkg.TOML.ParserError(12, 33, "expected a newline after a key")
Stacktrace:
[1] parse(::IOStream) at /home/cody/src/julia_1/usr/share/julia/stdlib/v1.0/Pkg/ext/TOML/src/TOML.jl:33
[2] #open#294(::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}, ::Function, ::typeof(Pkg.TOML.parse), ::String, ::Vararg{String,N} where N) at ./iostream.jl:369
[3] open at ./iostream.jl:367 [inlined]
[4] parsefile at /home/cody/src/julia_1/usr/share/julia/stdlib/v1.0/Pkg/ext/TOML/src/TOML.jl:46 [inlined]
[5] #parse_toml#17 at /home/cody/src/julia_1/usr/share/julia/stdlib/v1.0/Pkg/src/Types.jl:222 [inlined]
[6] parse_toml at /home/cody/src/julia_1/usr/share/julia/stdlib/v1.0/Pkg/src/Types.jl:221 [inlined]
[7] load_versions(::String) at /home/cody/src/julia_1/usr/share/julia/stdlib/v1.0/Pkg/src/Operations.jl:27
[8] deps_graph(::Pkg.Types.Context, ::Dict{Base.UUID,String}, ::Dict{Base.UUID,Pkg.Types.VersionSpec}, ::Dict{Base.UUID,Pkg.Types.Fixed}) at /home/cody/src/julia_1/usr/share/julia/stdlib/v1.0/Pkg/src/Operations.jl:269
[9] resolve_versions!(::Pkg.Types.Context, ::Array{Pkg.Types.PackageSpec,1}, ::Nothing) at /home/cody/src/julia_1/usr/share/julia/stdlib/v1.0/Pkg/src/Operations.jl:371
[10] resolve_versions! at /home/cody/src/julia_1/usr/share/julia/stdlib/v1.0/Pkg/src/Operations.jl:316 [inlined]
[11] up(::Pkg.Types.Context, ::Array{Pkg.Types.PackageSpec,1}) at /home/cody/src/julia_1/usr/share/julia/stdlib/v1.0/Pkg/src/Operations.jl:1244
[12] #up#29(::Pkg.Types.UpgradeLevel, ::Pkg.Types.PackageMode, ::Bool, ::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}, ::Function, ::Pkg.Types.Context, ::Array{Pkg.Types.PackageSpec,1}) at /home/cody/src/julia_1/usr/share/julia/stdlib/v1.0/Pkg/src/API.jl:198
[13] #up at ./none:0 [inlined]
[14] #up#24 at /home/cody/src/julia_1/usr/share/julia/stdlib/v1.0/Pkg/src/API.jl:163 [inlined]
[15] #up at ./none:0 [inlined]
[16] resolve at /home/cody/src/julia_1/usr/share/julia/stdlib/v1.0/Pkg/src/API.jl:203 [inlined]
[17] do_resolve!(::Dict{Symbol,Any}, ::Array{String,1}, ::Dict{Symbol,Any}) at /home/cody/src/julia_1/usr/share/julia/stdlib/v1.0/Pkg/src/REPLMode.jl:665
[18] #invokelatest#1(::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}, ::Function, ::Any, ::Any, ::Vararg{Any,N} where N) at ./essentials.jl:697
[19] invokelatest(::Any, ::Any, ::Vararg{Any,N} where N) at ./essentials.jl:696
[20] do_cmd!(::Pkg.REPLMode.PkgCommand, ::REPL.LineEditREPL) at /home/cody/src/julia_1/usr/share/julia/stdlib/v1.0/Pkg/src/REPLMode.jl:603
[21] #do_cmd#33(::Bool, ::Function, ::REPL.LineEditREPL, ::String) at /home/cody/src/julia_1/usr/share/julia/stdlib/v1.0/Pkg/src/REPLMode.jl:577
[22] do_cmd at /home/cody/src/julia_1/usr/share/julia/stdlib/v1.0/Pkg/src/REPLMode.jl:573 [inlined]
[23] (::getfield(Pkg.REPLMode, Symbol("##50#53")){REPL.LineEditREPL,REPL.LineEdit.Prompt})(::REPL.LineEdit.MIState, ::Base.GenericIOBuffer{Array{UInt8,1}}, ::Bool) at /home/cody/src/julia_1/usr/share/julia/stdlib/v1.0/Pkg/src/REPLMode.jl:923
[24] #invokelatest#1 at ./essentials.jl:697 [inlined]
[25] invokelatest at ./essentials.jl:696 [inlined]
[26] run_interface(::REPL.Terminals.TextTerminal, ::REPL.LineEdit.ModalInterface, ::REPL.LineEdit.MIState) at /home/cody/src/julia_1/usr/share/julia/stdlib/v1.0/REPL/src/LineEdit.jl:2273
[27] run_frontend(::REPL.LineEditREPL, ::REPL.REPLBackendRef) at /home/cody/src/julia_1/usr/share/julia/stdlib/v1.0/REPL/src/REPL.jl:1034
[28] run_repl(::REPL.AbstractREPL, ::Any) at /home/cody/src/julia_1/usr/share/julia/stdlib/v1.0/REPL/src/REPL.jl:191
[29] (::getfield(Base, Symbol("##718#720")){Bool,Bool,Bool,Bool})(::Module) at ./client.jl:355
[30] #invokelatest#1 at ./essentials.jl:697 [inlined]
[31] invokelatest at ./essentials.jl:696 [inlined]
[32] run_main_repl(::Bool, ::Bool, ::Bool, ::Bool, ::Bool) at ./client.jl:339
[33] exec_options(::Base.JLOptions) at ./client.jl:277
[34] _start() at ./client.jl:425
Can you post the project and manifest files?
After posting this I removed and re-added several dependencies from the command line and eventually this error went away for a reason that I don't understand. It couldn't be the manifest file, because I deleted it to simplify debugging. The Project.toml files that are now working are below:
Parent package Project.toml ("Imagine" is the problematic dependency)
```name = "EmpiricalTiming"
uuid = "99b0285a-20f0-11e9-0283-7f418f478feb"
version = "0.1.0"
[deps]
AxisArrays = "39de3d68-74b9-583c-8d2d-e117c070f3a9"
CoordinateTransformations = "150eb455-5306-5404-9cee-2592286d6298"
Images = "916415d5-f1e6-5110-898d-aaa5f9f070e0"
Imagine = "28fce3f0-1dbc-11e9-10e3-e71e6ceb4e7c"
ImagineInterface = "a9d8408c-0fb1-11e9-0067-cb067474114e"
ImagineProcedures = "43b7f2cc-1a9d-11e9-093e-178b9f97357d"
MappedArrays = "dbb5928d-eab1-5f90-85c2-b9b0edb7c900"
NIDAQ = "66b72792-1abf-55ab-8064-6e9051317175"
PaddedViews = "5432bcbf-9aad-5242-b902-cca2824c8663"
ProgressMeter = "92933f4c-e287-5a05-a399-4b506db050ca"
RegisterMismatch = "3c0dd727-6833-5f5d-a1e8-c0d421935c74"
Unitful = "1986cc42-f94f-5a68-af5c-568840ba703d"
[extras]
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
Imagine's Project.toml:
name = "Imagine"
uuid = "28fce3f0-1dbc-11e9-10e3-e71e6ceb4e7c"
version = "0.1.0"
[deps]
Distributed = "8ba89e20-285c-5b6f-9357-94700520ee1b"
ImagineFormat = "4bab44a2-5ff2-5a6b-8e10-825fb9ac126a"
ImagineInterface = "a9d8408c-0fb1-11e9-0067-cb067474114e"
ImagineWorker = "ff578f10-1de7-11e9-075b-65d52eaf0ec5"
NIDAQ = "66b72792-1abf-55ab-8064-6e9051317175"
Unitful = "1986cc42-f94f-5a68-af5c-568840ba703d"
```
I looked at the whitespace in both of these files before and after I got rid of the error, and I found no whitespace difference (and I never manually edited the files so if there was a whitespace problem it wasn't introduced by me).
Since I can no longer reproduce this I guess I'll close it.
I encountered this again in a different and simpler situation. When I dev my (unregistered) CachedArrays package I get the error in julia 1.0, but not in julia 0.7. Again, here's the error:
(v1.0) pkg> dev CachedArrays
Resolving package versions...
ERROR: Pkg.TOML.ParserError(12, 33, "expected a newline after a key")
Stacktrace:
[1] parse(::IOStream) at /home/cody/src/julia_1/usr/share/julia/stdlib/v1.0/Pkg/ext/TOML/src/TOML.jl:33
[2] #open#294(::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}, ::Function, ::typeof(Pkg.TOML.parse), ::String, ::Vararg{String,N} where N) at ./iostream.jl:369
[3] open at ./iostream.jl:367 [inlined]
[4] parsefile at /home/cody/src/julia_1/usr/share/julia/stdlib/v1.0/Pkg/ext/TOML/src/TOML.jl:46 [inlined]
[5] #parse_toml#17 at /home/cody/src/julia_1/usr/share/julia/stdlib/v1.0/Pkg/src/Types.jl:222 [inlined]
[6] parse_toml at /home/cody/src/julia_1/usr/share/julia/stdlib/v1.0/Pkg/src/Types.jl:221 [inlined]
[7] load_versions(::String) at /home/cody/src/julia_1/usr/share/julia/stdlib/v1.0/Pkg/src/Operations.jl:27
[8] deps_graph(::Pkg.Types.Context, ::Dict{Base.UUID,String}, ::Dict{Base.UUID,Pkg.Types.VersionSpec}, ::Dict{Base.UUID,Pkg.Types.Fixed}) at /home/cody/src/julia_1/usr/share/julia/stdlib/v1.0/Pkg/src/Operations.jl:269
[9] resolve_versions!(::Pkg.Types.Context, ::Array{Pkg.Types.PackageSpec,1}, ::Nothing) at /home/cody/src/julia_1/usr/share/julia/stdlib/v1.0/Pkg/src/Operations.jl:371
[10] resolve_versions! at /home/cody/src/julia_1/usr/share/julia/stdlib/v1.0/Pkg/src/Operations.jl:316 [inlined]
[11] #add_or_develop#62(::Array{Base.UUID,1}, ::Symbol, ::Function, ::Pkg.Types.Context, ::Array{Pkg.Types.PackageSpec,1}) at /home/cody/src/julia_1/usr/share/julia/stdlib/v1.0/Pkg/src/Operations.jl:1201
[12] #add_or_develop at ./none:0 [inlined]
[13] #add_or_develop#13(::Symbol, ::Bool, ::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}, ::Function, ::Pkg.Types.Context, ::Array{Pkg.Types.PackageSpec,1}) at /home/cody/src/julia_1/usr/share/julia/stdlib/v1.0/Pkg/src/API.jl:64
[14] (::getfield(Pkg.API, Symbol("#kw##add_or_develop")))(::NamedTuple{(:mode,),Tuple{Symbol}}, ::typeof(Pkg.API.add_or_develop), ::Pkg.Types.Context, ::Array{Pkg.Types.PackageSpec,1}) at ./none:0
[15] do_develop!(::Dict{Symbol,Any}, ::Array{Pkg.Types.PackageSpec,1}, ::Dict{Symbol,Any}) at /home/cody/src/julia_1/usr/share/julia/stdlib/v1.0/Pkg/src/REPLMode.jl:714
[16] #invokelatest#1(::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}, ::Function, ::Any, ::Any, ::Vararg{Any,N} where N) at ./essentials.jl:697
[17] invokelatest(::Any, ::Any, ::Vararg{Any,N} where N) at ./essentials.jl:696
[18] do_cmd!(::Pkg.REPLMode.PkgCommand, ::REPL.LineEditREPL) at /home/cody/src/julia_1/usr/share/julia/stdlib/v1.0/Pkg/src/REPLMode.jl:603
[19] #do_cmd#33(::Bool, ::Function, ::REPL.LineEditREPL, ::String) at /home/cody/src/julia_1/usr/share/julia/stdlib/v1.0/Pkg/src/REPLMode.jl:577
[20] do_cmd at /home/cody/src/julia_1/usr/share/julia/stdlib/v1.0/Pkg/src/REPLMode.jl:573 [inlined]
[21] (::getfield(Pkg.REPLMode, Symbol("##50#53")){REPL.LineEditREPL,REPL.LineEdit.Prompt})(::REPL.LineEdit.MIState, ::Base.GenericIOBuffer{Array{UInt8,1}}, ::Bool) at /home/cody/src/julia_1/usr/share/julia/stdlib/v1.0/Pkg/src/REPLMode.jl:923
[22] #invokelatest#1 at ./essentials.jl:697 [inlined]
[23] invokelatest at ./essentials.jl:696 [inlined]
[24] run_interface(::REPL.Terminals.TextTerminal, ::REPL.LineEdit.ModalInterface, ::REPL.LineEdit.MIState) at /home/cody/src/julia_1/usr/share/julia/stdlib/v1.0/REPL/src/LineEdit.jl:2273
[25] run_frontend(::REPL.LineEditREPL, ::REPL.REPLBackendRef) at /home/cody/src/julia_1/usr/share/julia/stdlib/v1.0/REPL/src/REPL.jl:1034
[26] run_repl(::REPL.AbstractREPL, ::Any) at /home/cody/src/julia_1/usr/share/julia/stdlib/v1.0/REPL/src/REPL.jl:191
[27] (::getfield(Base, Symbol("##718#720")){Bool,Bool,Bool,Bool})(::Module) at ./client.jl:355
[28] #invokelatest#1 at ./essentials.jl:697 [inlined]
[29] invokelatest at ./essentials.jl:696 [inlined]
[30] run_main_repl(::Bool, ::Bool, ::Bool, ::Bool, ::Bool) at ./client.jl:339
[31] exec_options(::Base.JLOptions) at ./client.jl:277
[32] _start() at ./client.jl:425
The Project.toml is pasted below. There's no REQUIRE. Note all dependencies are public, registered packages.
name = "CachedArrays"
uuid = "d8fd01e4-1764-11e9-0a01-8f76bebf08d8"
version = "0.1.0"
[deps]
AxisArrays = "39de3d68-74b9-583c-8d2d-e117c070f3a9"
Images = "916415d5-f1e6-5110-898d-aaa5f9f070e0"
Unitful = "1986cc42-f94f-5a68-af5c-568840ba703d"
[compat]
julia = ">= 0.7"
[extras]
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
[targets]
test = ["Test"]
Any ideas about this? I just encountered it again with another package. In case it helps my workflow is:
Project.toml, and verify that it's sufficient by removing the REQUIRE file.Pkg.dev the package directory. That's when I get the TOML parse error.Probably some error in the TOML printer shipped with julia 0.7.
Strange, that looks like a valid TOML file and I can also parse after downloading it.
> VERSION
v"1.1.0"
> Pkg.TOML.parsefile("../../Documents\\test.toml")
Dict{String,Any} with 7 entries:
"deps" => Dict{String,Any}("Unitful"=>"1986cc42-f94f-5a68-af5c-568840ba703d","…
"name" => "CachedArrays"
"extras" => Dict{String,Any}("Test"=>"8dfed614-e22c-5e08-85e1-65c5234f0b40")
"uuid" => "d8fd01e4-1764-11e9-0a01-8f76bebf08d8"
"compat" => Dict{String,Any}("julia"=>">= 0.7")
"targets" => Dict{String,Any}("test"=>["Test"])
"version" => "0.1.0"
Could it be something with weird line endings?
The error expected a newline after a key points to a multiple keys were written without newline separator. So that must be a TOML.print call in write_project.
Actually, load_versions is reading files from the registry so perhaps it is there...
We should really make the parse error write out the file it is trying to parse...
Probably some error in the TOML printer shipped with julia 0.7.
I haven't seen the error in julia 0.7, only in 1.0
Strange, that looks like a valid TOML file and I can also parse after downloading it.
Yes when I try parsefile on the Project.toml I also don't get the error. My feeling is that it's coming from another toml file, perhaps in a registry or the environment. Maybe it errors on some intermediate file that hasn't been written to disk yet? The environment files also parse correctly with parsefile.
Edit: I just realized I don't get the error with Julia 1.1, so the problem is very specific to Julia 1.0.
I've just encountered this again. It's the first time it's happened in Julia 1.1.1. I wonder if this problem is specific to using a private registry, since I seem to be the only one running into this and I don't think private registries are commonly used. Here's the stack trace from Travis in case it's useful:
julia -e 'using Pkg; Pkg.build(); Pkg.test("EmpiricalTiming"; coverage=true)'
Updating registry at `~/.julia/registries/General`
Updating git-repo `https://github.com/JuliaRegistries/General.git`
Updating registry at `~/.julia/registries/HolyLabRegistry`
Updating git-repo `https://github.com/HolyLab/HolyLabRegistry.git`
Resolving package versions...
ERROR: Pkg.TOML.ParserError(12, 33, "expected a newline after a key")
Stacktrace:
[1] parse(::IOStream) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.1/Pkg/ext/TOML/src/TOML.jl:33
[2] #open#310(::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}, ::Function, ::typeof(Pkg.TOML.parse), ::String, ::Vararg{String,N} where N) at ./iostream.jl:375
[3] open at ./iostream.jl:373 [inlined]
[4] parsefile at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.1/Pkg/ext/TOML/src/TOML.jl:46 [inlined]
[5] #parse_toml#29 at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.1/Pkg/src/Types.jl:190 [inlined]
[6] #parse_toml at ./none:0 [inlined]
[7] #load_versions#1(::Bool, ::Function, ::String) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.1/Pkg/src/Operations.jl:27
[8] #load_versions at ./array.jl:0 [inlined]
[9] deps_graph(::Pkg.Types.Context, ::Dict{Base.UUID,String}, ::Dict{Base.UUID,Pkg.Types.VersionSpec}, ::Dict{Base.UUID,Pkg.Types.Fixed}) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.1/Pkg/src/Operations.jl:268
[10] resolve_versions!(::Pkg.Types.Context, ::Array{Pkg.Types.PackageSpec,1}, ::Nothing) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.1/Pkg/src/Operations.jl:369
[11] resolve_versions! at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.1/Pkg/src/Operations.jl:315 [inlined]
[12] up(::Pkg.Types.Context, ::Array{Pkg.Types.PackageSpec,1}) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.1/Pkg/src/Operations.jl:1215
[13] #up#33(::Pkg.Types.UpgradeLevel, ::Pkg.Types.PackageMode, ::Bool, ::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}, ::Function, ::Pkg.Types.Context, ::Array{Pkg.Types.PackageSpec,1}) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.1/Pkg/src/API.jl:123
[14] #up#28 at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.1/Pkg/src/API.jl:95 [inlined]
[15] up at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.1/Pkg/src/API.jl:87 [inlined]
[16] #instantiate#67(::Nothing, ::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}, ::Function, ::Pkg.Types.Context) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.1/Pkg/src/API.jl:444
[17] instantiate at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.1/Pkg/src/API.jl:442 [inlined]
[18] #build#61(::Bool, ::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}, ::Function, ::Pkg.Types.Context, ::Array{Pkg.Types.PackageSpec,1}) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.1/Pkg/src/API.jl:377
[19] build at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.1/Pkg/src/API.jl:357 [inlined]
[20] #build#60 at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.1/Pkg/src/API.jl:355 [inlined]
[21] build at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.1/Pkg/src/API.jl:355 [inlined]
[22] #build#57 at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.1/Pkg/src/API.jl:352 [inlined]
[23] build() at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.1/Pkg/src/API.jl:352
[24] top-level scope at none:0
The command "julia -e 'using Pkg; Pkg.build(); Pkg.test("EmpiricalTiming"; coverage=true)'" exited with 1.
FWIW, I'm hitting this too, using a private registry. Can't figure out which file is causing the hangup but everything so far looks like valid toml.
You can probably just recursively TOML.parsefile the files to figure out which file is corrupt.
Thanks to both of you for replying.
You can probably just recursively TOML.parsefile the files to figure out which file is corrupt.
Which TOML files do you mean? I've tried parsefile on the files in the repository and they're all fine. I don't expect to find any problems in the registry TOML files either, because I've often encountered this error after changes to the local repository, _without_ changes to the registry. Are there any intermediate TOML files generated by Pkg that don't get written to disk?
I don't expect to find any problems in the registry TOML files either
Nevermind, my expectation was wrong. In this case the problem was that one of the uuids in Versions.toml was missing quotes. Maybe I was mistaken and this will explain all the failure cases. @sbromberger I found the problem file with the script below in case it's useful (run it from the registry directory). If that solves your problem too then maybe we can close this issue...or we can convert this to a feature request to print the problematic TOML file on failures?
using Pkg.TOML
contents = readdir()
for c in contents
if isdir(c)
print("Entering $c\n")
cd(c)
files = readdir(".")
for f in files
if splitext(f)[2] == ".toml"
print("parsing $f\n")
TOML.parsefile(f)
end
end
cd("..")
end
end
Entering General
parsing Registry.toml
Entering LocalRegistry
parsing Registry.toml
It seems not to have any problems with the registry, but I'm still getting the error.
Found the problem. It was in my Package.toml file - the uuid was not quoted. (Same issue, different file.) Thanks.
How did you end up with an unquoted UUID in the file? Was it manually edited or is there some tool that is incorrectly emitting unquoted UUIDs as TOML values?
How did you end up with an unquoted UUID in the file?
Manually edited using https://discourse.julialang.org/t/creating-a-registry/12094 as a guide (see the "TestPackage/Package.toml" section).
Ok, I've edited that post to quote the UUID so that others don't copy it and have the same issue.
Great, thanks! Is there interest in having Pkg print the file name when TOML parsing fails? If not I think we can close this.
Printing the file name would certainly be an improvement 👍
This seems related:
julia> VERSION
v"1.0.5"
julia> sprint(TOML.print, Dict("uuid" => uuid4()))
"uuid = 158130ac-3fad-490a-a649-fed4e96be804\n"
julia> VERSION
v"1.2.0"
julia> sprint(TOML.print, Dict("uuid" => uuid4()))
"uuid = \"520ef032-5d4c-4589-91ba-6a068779e8f1\"\n"
Right. The question is how did a bare UUID on the RHS get in there?
Maybe error on unknown types instead of getting whatever implementation behavior one gets?
The behavior is sort-of correct. One is bare print of the UUID, and another is a string that contains UUID. See https://github.com/wildart/TOML.jl/blob/master/src/print.jl#L33-L38
julia> VERSION
v"1.1.0"
julia> sprint(TOML.print, Dict("uuid" => uuid4()))
"uuid = 281db77e-f542-4df0-9817-a2ecb78f640d\n"
julia> sprint(TOML.print, Dict("uuid" => string(uuid4())))
"uuid = \"142b93b8-0915-4be4-bc5b-e6b4b2fd5c11\"\n"
TOML doesn't have type for UUID, thus UUIDs need to be converted to the string type before printing. I think it would be correct to assume that any non-designated by TOML standard type have to be implicitly converted to string.
julia> sprint(TOML.print, Dict("uuid" => string(uuid4()))) |> TOML.parse
Dict{AbstractString,Any} with 1 entry:
"uuid" => "378c5c75-9ce3-44da-b807-ccec0341a235"
julia> sprint(TOML.print, Dict("uuid" => uuid4())) |> TOML.parse
ERROR: TOML.ParserError(2, 12, "expected a newline after a key")
Stacktrace:
[1] parse(::Base.GenericIOBuffer{Array{UInt8,1}}) at /home/art/.julia/packages/TOML/3xkeO/src/TOML.jl:32
[2] parse at /home/art/.julia/packages/TOML/3xkeO/src/TOML.jl:39 [inlined]
[3] |>(::String, ::typeof(TOML.parse)) at ./operators.jl:813
[4] top-level scope at none:0
Oh, oops. I just now realize that my example was wrong. I didn't mean to have that string call in the 1.2 version.
julia> VERSION
v"1.2.0"
julia> sprint(TOML.print, Dict("uuid" => uuid4()))
"uuid = \"dacc8dc7-7e67-4366-98ac-17ae371e1eb7\"\n"
The UUID is properly quoted, and the behaviour of the same code differs between Julia versions. That IMO is a bug in some way.
Behavior in 1.2.0 is correct. Any non-standard datatype is stringyfied.
https://github.com/JuliaLang/Pkg.jl/blob/e5b9816594e30c05a6651d351f0cbac6a10ca526/ext/TOML/src/print.jl#L45-L46
Yeah, my point is that should probably be backported into 1.0 if it's not already planned/done :slightly_smiling_face:
TOML stdlib doesn't blindly stringify types when printing, you need to opt into it. The error messages on parsing are also better. Don't think there is anything to do here.
Most helpful comment
Actually,
load_versionsis reading files from the registry so perhaps it is there...We should really make the parse error write out the file it is trying to parse...