TimeZones.jl icon indicating copy to clipboard operation
TimeZones.jl copied to clipboard

Error after compilation - Unable to find time zone "Europe/Budapest". Try running `TimeZones.build()`

Open JakubPorubcansky opened this issue 3 years ago • 2 comments

I am trying to compile this minimal example package to an app

TestPackage.jl
module TestPackage

using TimeZones

function julia_main()::Cint
  try
    @info "Start"
    sleep(3)
    timeZone = TimeZone("Europe/Budapest")
    @info "timeZone=$timeZone"
    sleep(3)
    @info "Finish"
  catch exc
    @error "Something went wrong" exception=(exc, catch_backtrace())
    return 1
  end
  return 0
end

end # module

Project.toml
name = "TestPackage"
uuid = "d2663e91-0ef1-41e5-8c08-2797f1a8a949"
authors = ["Jakub Porubcansky <[email protected]"]
version = "0.1.0"

[deps]
TimeZones = "f269a46b-ccf7-5d73-abea-4c690281aa53"
Manifest.toml
# This file is machine-generated - editing it directly is not advised

julia_version = "1.7.3"
manifest_format = "2.0"

[[deps.ArgTools]]
uuid = "0dad84c5-d112-42e6-8d28-ef12dabb789f"

[[deps.Artifacts]]
uuid = "56f22d72-fd6d-98f1-02f0-08ddc0907c33"

[[deps.Base64]]
uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"

[[deps.Compat]]
deps = ["Base64", "Dates", "DelimitedFiles", "Distributed", "InteractiveUtils", "LibGit2", "Libdl", "LinearAlgebra", "Markdown", "Mmap", "Pkg", "Printf", "REPL", "Random", "SHA", "Serialization", "SharedArrays", "Sockets", "SparseArrays", "Statistics", "Test", "UUIDs", "Unicode"]
git-tree-sha1 = "9be8be1d8a6f44b96482c8af52238ea7987da3e3"
uuid = "34da2185-b29b-5c13-b0c7-acf172513d20"
version = "3.45.0"

[[deps.CompilerSupportLibraries_jll]]
deps = ["Artifacts", "Libdl"]
uuid = "e66e0078-7015-5450-92f7-15fbd957f2ae"

[[deps.Dates]]
deps = ["Printf"]
uuid = "ade2ca70-3891-5945-98fb-dc099432e06a"

[[deps.DelimitedFiles]]
deps = ["Mmap"]
uuid = "8bb1440f-4735-579b-a4ab-409b98df4dab"

[[deps.Distributed]]
deps = ["Random", "Serialization", "Sockets"]
uuid = "8ba89e20-285c-5b6f-9357-94700520ee1b"

[[deps.Downloads]]
deps = ["ArgTools", "FileWatching", "LibCURL", "NetworkOptions"]
uuid = "f43a241f-c20a-4ad4-852c-f6b1247861c6"

[[deps.ExprTools]]
git-tree-sha1 = "56559bbef6ca5ea0c0818fa5c90320398a6fbf8d"
uuid = "e2ba6199-217a-4e67-a87a-7c52f15ade04"
version = "0.1.8"

[[deps.FileWatching]]
uuid = "7b1f6079-737a-58dc-b8bc-7a2ca5c1b5ee"

[[deps.InlineStrings]]
deps = ["Parsers"]
git-tree-sha1 = "d19f9edd8c34760dca2de2b503f969d8700ed288"
uuid = "842dd82b-1e85-43dc-bf29-5d0ee9dffc48"
version = "1.1.4"

[[deps.InteractiveUtils]]
deps = ["Markdown"]
uuid = "b77e0a4c-d291-57a0-90e8-8db25a27a240"

[[deps.LazyArtifacts]]
deps = ["Artifacts", "Pkg"]
uuid = "4af54fe1-eca0-43a8-85a7-787d91b784e3"

[[deps.LibCURL]]
deps = ["LibCURL_jll", "MozillaCACerts_jll"]
uuid = "b27032c2-a3e7-50c8-80cd-2d36dbcbfd21"

[[deps.LibCURL_jll]]
deps = ["Artifacts", "LibSSH2_jll", "Libdl", "MbedTLS_jll", "Zlib_jll", "nghttp2_jll"]
uuid = "deac9b47-8bc7-5906-a0fe-35ac56dc84c0"

[[deps.LibGit2]]
deps = ["Base64", "NetworkOptions", "Printf", "SHA"]
uuid = "76f85450-5226-5b5a-8eaa-529ad045b433"

[[deps.LibSSH2_jll]]
deps = ["Artifacts", "Libdl", "MbedTLS_jll"]
uuid = "29816b5a-b9ab-546f-933c-edad1886dfa8"

[[deps.Libdl]]
uuid = "8f399da3-3557-5675-b5ff-fb832c97cbdb"

[[deps.LinearAlgebra]]
deps = ["Libdl", "libblastrampoline_jll"]
uuid = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"

[[deps.Logging]]
uuid = "56ddb016-857b-54e1-b83d-db4d58db5568"

[[deps.Markdown]]
deps = ["Base64"]
uuid = "d6f4376e-aef5-505a-96c1-9c027394607a"

[[deps.MbedTLS_jll]]
deps = ["Artifacts", "Libdl"]
uuid = "c8ffd9c3-330d-5841-b78e-0817d7145fa1"

[[deps.Mmap]]
uuid = "a63ad114-7e13-5084-954f-fe012c677804"

[[deps.Mocking]]
deps = ["Compat", "ExprTools"]
git-tree-sha1 = "29714d0a7a8083bba8427a4fbfb00a540c681ce7"
uuid = "78c3b35d-d492-501b-9361-3d52fe80e533"
version = "0.7.3"

[[deps.MozillaCACerts_jll]]
uuid = "14a3606d-f60d-562e-9121-12d972cd8159"

[[deps.NetworkOptions]]
uuid = "ca575930-c2e3-43a9-ace4-1e988b2c1908"

[[deps.OpenBLAS_jll]]
deps = ["Artifacts", "CompilerSupportLibraries_jll", "Libdl"]
uuid = "4536629a-c528-5b80-bd46-f80d51c5b363"

[[deps.Parsers]]
deps = ["Dates"]
git-tree-sha1 = "0044b23da09b5608b4ecacb4e5e6c6332f833a7e"
uuid = "69de0a69-1ddd-5017-9359-2bf0b02dc9f0"
version = "2.3.2"

[[deps.Pkg]]
deps = ["Artifacts", "Dates", "Downloads", "LibGit2", "Libdl", "Logging", "Markdown", "Printf", "REPL", "Random", "SHA", "Serialization", "TOML", "Tar", "UUIDs", "p7zip_jll"]
uuid = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"

[[deps.Printf]]
deps = ["Unicode"]
uuid = "de0858da-6303-5e67-8744-51eddeeeb8d7"

[[deps.REPL]]
deps = ["InteractiveUtils", "Markdown", "Sockets", "Unicode"]
uuid = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb"

[[deps.Random]]
deps = ["SHA", "Serialization"]
uuid = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"

[[deps.RecipesBase]]
git-tree-sha1 = "6bf3f380ff52ce0832ddd3a2a7b9538ed1bcca7d"
uuid = "3cdcf5f2-1ef4-517c-9805-6587b60abb01"
version = "1.2.1"

[[deps.SHA]]
uuid = "ea8e919c-243c-51af-8825-aaa63cd721ce"

[[deps.Scratch]]
deps = ["Dates"]
git-tree-sha1 = "f94f779c94e58bf9ea243e77a37e16d9de9126bd"
uuid = "6c6a2e73-6563-6170-7368-637461726353"
version = "1.1.1"

[[deps.Serialization]]
uuid = "9e88b42a-f829-5b0c-bbe9-9e923198166b"

[[deps.SharedArrays]]
deps = ["Distributed", "Mmap", "Random", "Serialization"]
uuid = "1a1011a3-84de-559e-8e89-a11a2f7dc383"

[[deps.Sockets]]
uuid = "6462fe0b-24de-5631-8697-dd941f90decc"

[[deps.SparseArrays]]
deps = ["LinearAlgebra", "Random"]
uuid = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"

[[deps.Statistics]]
deps = ["LinearAlgebra", "SparseArrays"]
uuid = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"

[[deps.TOML]]
deps = ["Dates"]
uuid = "fa267f1f-6049-4f14-aa54-33bafae1ed76"

[[deps.Tar]]
deps = ["ArgTools", "SHA"]
uuid = "a4e569a6-e804-4fa4-b0f3-eef7a1d5b13e"

[[deps.Test]]
deps = ["InteractiveUtils", "Logging", "Random", "Serialization"]
uuid = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[[deps.TimeZones]]
deps = ["Dates", "Downloads", "InlineStrings", "LazyArtifacts", "Mocking", "Printf", "RecipesBase", "Scratch", "Unicode"]
git-tree-sha1 = "d634a3641062c040fc8a7e2a3ea17661cc159688"
uuid = "f269a46b-ccf7-5d73-abea-4c690281aa53"
version = "1.9.0"

[[deps.UUIDs]]
deps = ["Random", "SHA"]
uuid = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"

[[deps.Unicode]]
uuid = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5"

[[deps.Zlib_jll]]
deps = ["Libdl"]
uuid = "83775a58-1f1d-513f-b197-d71354ab007a"

[[deps.libblastrampoline_jll]]
deps = ["Artifacts", "Libdl", "OpenBLAS_jll"]
uuid = "8e850b90-86db-534c-a0d3-1478176c7d93"

[[deps.nghttp2_jll]]
deps = ["Artifacts", "Libdl"]
uuid = "8e850ede-7688-5339-a07c-302acd2aaf8d"

[[deps.p7zip_jll]]
deps = ["Artifacts", "Libdl"]
uuid = "3f19e933-33d8-53b3-aaab-bd5110c3b7a0"

However, when running the app, it gives the following error:

[ Info: Start
┌ Error: Something went wrong
│   exception =
│    ArgumentError: Unable to find time zone "Europe/Budapest". Try running `TimeZones.build()`.
│    Stacktrace:
│     [1] (::TimeZones.var"#3#4"{String})()
│       @ TimeZones ~/.julia/packages/TimeZones/2oXvO/src/types/timezone.jl:80
│     [2] get!
│       @ ./dict.jl:464 [inlined]
│     [3] Dates.TimeZone(str::String, mask::TimeZones.Class) (repeats 2 times)
│       @ TimeZones ~/.julia/packages/TimeZones/2oXvO/src/types/timezone.jl:70
│     [4] julia_main()
│       @ TestPackage /TestPackage/src/TestPackage.jl:9
│     [5] top-level scope
│       @ none:1
└ @ TestPackage /TestPackage/src/TestPackage.jl:14

To compile the app I run Docker build using the following Dockerfile

Dockerfile
FROM julia:1.7.3-bullseye AS builder

RUN dpkg-reconfigure dash && \
    apt-get update && \
    apt-get dist-upgrade -y

RUN apt-get -y install \
    build-essential

COPY . TestPackage

RUN julia --project=TestPackage -e "using Pkg; Pkg.instantiate(); Pkg.precompile();"

RUN julia -e "using Pkg; \
              pkg\"add PackageCompiler\"; \
              using PackageCompiler; \
              create_app(\"TestPackage\", \"app\")"

ENTRYPOINT ["/app/bin/TestPackage"]       

The output of Docker build command:

Docker build output

#1 [internal] load build definition from Dockerfile #1 sha256:a83776a614dd23bbd63c4d2c4c60723431b8e0d90f31fd346553323385bebbb1 #1 transferring dockerfile: 553B 0.0s done #1 DONE 0.5s

#2 [internal] load .dockerignore #2 sha256:0b5b39a11ca4d40b2d4a20a7efdad921f8632984297c077c3f05c57f8b1fa21b #2 transferring context: #2 transferring context: 2B 0.3s done #2 DONE 1.0s

#3 [internal] load metadata for docker.io/library/julia:1.7.3-bullseye #3 sha256:a709d3decc38ca0fa431dc40cebe2f400b71b387c30624c46c675d14129c2314 #3 DONE 5.5s

#4 [builder 1/7] FROM docker.io/library/julia:1.7.3-bullseye@sha256:02866dcc4be5385c9b67d33926992054db8e70286f5b4b61dec9e7cb28b605f6 #4 sha256:e098eab13fb22e037da857637320111c6c64afba1ac38cca691bc111a3d1adfd #4 resolve docker.io/library/julia:1.7.3-bullseye@sha256:02866dcc4be5385c9b67d33926992054db8e70286f5b4b61dec9e7cb28b605f6 0.0s done #4 DONE 0.0s

#5 [builder 2/7] RUN dpkg-reconfigure dash && apt-get update && apt-get dist-upgrade -y #5 sha256:f7e448225929c19688266c5178a5544814aa288621c92a97afd58fa319e86df6 #5 CACHED

#6 [builder 3/7] RUN apt-get -y install build-essential #6 sha256:c6952e6b44098cf110ec599ef9aa0f2513827486f00077cfcd96f31a5b3d0222 #6 CACHED

#7 [internal] load build context #7 sha256:0ad9b42a4a861dde482d1aea8eaebaa9226d85e5fc01d86b694ca04d46fb2166 #7 transferring context: #7 transferring context: 1.25kB 0.1s done #7 DONE 0.4s

#8 [4/6] COPY . TestPackage #8 sha256:51bee2a57409e468510305b50b87b30c82b4ae08b3312ba9b192b334bdbc8cd6 #8 DONE 0.7s

#9 [5/6] RUN julia --project=TestPackage -e "using Pkg; Pkg.instantiate(); Pkg.precompile();" #9 sha256:ce9eb6914f3ae039e353f5a9cc566a5577cd8a53be003d81245c3773696aa21e #9 6.817 Installing known registries into ~/.julia #9 20.25 Installed Scratch ─────── v1.1.1 #9 20.26 Installed Mocking ─────── v0.7.3 #9 20.26 Installed Parsers ─────── v2.3.2 #9 20.26 Installed InlineStrings ─ v1.1.4 #9 20.26 Installed ExprTools ───── v0.1.8 #9 20.28 Installed Compat ──────── v3.45.0 #9 20.28 Installed RecipesBase ─── v1.2.1 #9 20.28 Installed TimeZones ───── v1.9.0 #9 24.83 Building TimeZones → ~/.julia/scratchspaces/44cfe95a-1eb2-52ea-b672-e2afdf69b78f/d634a3641062c040fc8a7e2a3ea17661cc159688/build.log #9 122.5 Precompiling project... #9 124.7 ✓ Zlib_jll #9 124.9 ✓ MbedTLS_jll #9 125.9 ✓ CompilerSupportLibraries_jll #9 126.8 ✓ LibSSH2_jll #9 127.7 ✓ OpenBLAS_jll #9 129.1 ✓ libblastrampoline_jll #9 131.9 ✓ TestPackage #9 132.2 7 dependencies successfully precompiled in 12 seconds (8 already precompiled) #9 DONE 133.4s

#10 [6/6] RUN julia -e "using Pkg; pkg"add PackageCompiler"; using PackageCompiler; create_app("TestPackage", "app")" #10 sha256:c7dfd4b50ddf5aee1e67c0c1e7592b81df8ece89106fbf1e5066f293a5349593 #10 3.447 ┌ Warning: The Pkg REPL mode is intended for interactive use only, and should not be used from scripts. It is recommended to use the functional API instead. #10 3.447 └ @ Pkg.REPLMode /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.7/Pkg/src/REPLMode/REPLMode.jl:377 #10 14.46 Updating registry at ~/.julia/registries/General.toml #10 15.67 Resolving package versions... #10 21.31 Installed RelocatableFolders ─ v0.1.3 #10 21.31 Installed PackageCompiler ──── v2.0.7 #10 24.22 Updating ~/.julia/environments/v1.7/Project.toml #10 24.22 [9b87118b] + PackageCompiler v2.0.7 #10 24.27 Updating ~/.julia/environments/v1.7/Manifest.toml #10 24.27 [9b87118b] + PackageCompiler v2.0.7 #10 24.27 [05181044] + RelocatableFolders v0.1.3 #10 24.27 [6c6a2e73] + Scratch v1.1.1 #10 24.27 [0dad84c5] + ArgTools #10 24.27 [56f22d72] + Artifacts #10 24.28 [2a0f44e3] + Base64 #10 24.28 [ade2ca70] + Dates #10 24.28 [f43a241f] + Downloads #10 24.28 [7b1f6079] + FileWatching #10 24.29 [b77e0a4c] + InteractiveUtils #10 24.29 [4af54fe1] + LazyArtifacts #10 24.29 [b27032c2] + LibCURL #10 24.29 [76f85450] + LibGit2 #10 24.30 [8f399da3] + Libdl #10 24.30 [56ddb016] + Logging #10 24.30 [d6f4376e] + Markdown #10 24.32 [ca575930] + NetworkOptions #10 24.32 [44cfe95a] + Pkg #10 24.32 [de0858da] + Printf #10 24.32 [3fa0cd96] + REPL #10 24.32 [9a3f8284] + Random #10 24.32 [ea8e919c] + SHA #10 24.32 [9e88b42a] + Serialization #10 24.32 [6462fe0b] + Sockets #10 24.32 [fa267f1f] + TOML #10 24.32 [a4e569a6] + Tar #10 24.32 [cf7118a7] + UUIDs #10 24.37 [4ec0a83e] + Unicode #10 24.37 [deac9b47] + LibCURL_jll #10 24.38 [29816b5a] + LibSSH2_jll #10 24.40 [c8ffd9c3] + MbedTLS_jll #10 24.40 [14a3606d] + MozillaCACerts_jll #10 24.40 [83775a58] + Zlib_jll #10 24.40 [8e850ede] + nghttp2_jll #10 27.42 Precompiling project... #10 28.53 ✓ RelocatableFolders #10 36.34 ✓ PackageCompiler #10 36.48 2 dependencies successfully precompiled in 12 seconds (4 already precompiled) #10 77.48 PackageCompiler: bundled artifacts: #10 77.48 └── TimeZones #10 77.50 └── tzdata2022a - 1.196 MiB #10 77.52 Total artifact file size: 1.196 MiB #10 84.97 - PackageCompiler: compiling base system image (incremental=false) #10 1126.3 Precompiling project... #10 1282.6 ✓ CompilerSupportLibraries_jll #10 1283.8 ✓ RecipesBase #10 1293.2 ✓ Compat #10 1316.6 ✓ Parsers #10 1395.6 ✓ Zlib_jll #10 1398.3 ✓ ExprTools #10 1402.3 ✓ Scratch #10 1407.6 ✓ LibSSH2_jll #10 1416.3 ✓ OpenBLAS_jll #10 1446.0 ✓ InlineStrings #10 1447.0 ✓ Mocking #10 1455.1 ✓ libblastrampoline_jll #10 1483.3 ✓ TimeZones #10 1511.6 ✓ TestPackage #10 1514.1 15 dependencies successfully precompiled in 395 seconds #10 1566.2 - PackageCompiler: compiling nonincremental system image

#11 exporting to image #11 sha256:e8c613e07b0b7ff33893b694f7759a10d42e180f2b4dc349fb57dc6b71dcab00 #11 exporting layers #11 exporting layers 4.3s done #11 writing image sha256:4372470e146819392c68f208c728b023994e680350cffb7df58b64c3533fda0a 0.0s done #11 naming to docker.io/library/test-pkg5 done #11 DONE 4.3s

JakubPorubcansky avatar Aug 03 '22 14:08 JakubPorubcansky

Related to https://github.com/JuliaTime/TimeZones.jl/issues/359. Having #390 would address your issue but not in the way you want as I'm sure you want all the application building to take place during the Docker image build and not at runtime.

omus avatar Aug 08 '22 20:08 omus

The answer to this is to make TimeZones.jl fully relocatable which requires us to make the artifact package which will finally close #359

omus avatar Aug 08 '22 20:08 omus

As of PR #441 this package uses precomputed time zones artifacts. Included in TimeZones release 1.12

omus avatar Aug 22 '23 04:08 omus