JuliaTime / TimeZones.jl

IANA time zone database access for the Julia programming language
Other
86 stars 51 forks source link

Initialization Error in PackageCompiler app on Windows when relocating #371

Closed Felix-Gauthier closed 2 years ago

Felix-Gauthier commented 2 years ago

There seems to be an initialization error in applications generated through PackageCompiler.jl using TimeZones.jl as a dependency on Windows when relocating to another computer (i.e. sharing a quick CLI app with a not-yet-converted-to-glorious-julia-prog colleague)

Consider the following:

Foo module ```julia module Foo using TimeZones function julia_main()::Cint try @info "Hello, World!" catch Base.invokelatest(Base.display_error, Base.catch_stack()) return 1 end return 0 end end # module ```

Generating the app with PackageCompiler v2.0.4 and TimeZones v1.7.0 (n.b. I have not tested with lower versions of each pkg)

using PackageCompiler; create_app("Foo", "./FooCompiled"; force=true, include_lazy_artifacts=true)

I initially thought the error was because of not including lazy artifacts, but I've tested both ways to make sure with same results

Error stacktrace ``` fatal: error thrown and no exception handler available. InitError(mod=:WindowsTimeZoneIDs, error=Base.IOError(msg="mkdir("C:\\Users\\user\\.julia\\packages\\TimeZones\\ZQ4lc\\deps\\local"; mode=0o777): no such file or directory (ENOENT)", code=-4058)) uv_error at .\libuv.jl:97 [inlined] #mkdir#10 at .\file.jl:183 mkdir at .\file.jl:176 [inlined] __init__ at C:\Users\user\.julia\packages\TimeZones\ZQ4lc\src\winzone\WindowsTimeZoneIDs.jl:19 jfptr___init___34981.clone_1 at C:\Users\user\Desktop\FooCompiled\FooCompiled\lib\julia\sys.dll (unknown line) jl_apply at /cygdrive/c/buildbot/worker/package_win64/build/src\julia.h:1788 [inlined] jl_module_run_initializer at /cygdrive/c/buildbot/worker/package_win64/build/src\toplevel.c:73 _finish_julia_init at /cygdrive/c/buildbot/worker/package_win64/build/src\init.c:796 jl_init_with_image at /cygdrive/c/buildbot/worker/package_win64/build/src\jlapi.c:74 [inlined] jl_init_with_image at /cygdrive/c/buildbot/worker/package_win64/build/src\jlapi.c:63 [inlined] jl_init at /cygdrive/c/buildbot/worker/package_win64/build/src\jlapi.c:90 .text at C:\Users\user\Desktop\FooCompiled\FooCompiled\bin\Foo.exe (unknown line) __tmainCRTStartup at C:\Users\user\Desktop\FooCompiled\FooCompiled\bin\Foo.exe (unknown line) .l_start at C:\Users\user\Desktop\FooCompiled\FooCompiled\bin\Foo.exe (unknown line) BaseThreadInitThunk at C:\WINDOWS\System32\KERNEL32.DLL (unknown line) RtlUserThreadStart at C:\WINDOWS\SYSTEM32\ntdll.dll (unknown line) ```

I've tested this on Windows 10 with julia 1.6.4 and 1.7.1 (to check if my recent Julia version update was the culprit) with the same error.

The error does not seem to occur on Linux (tested wih Ubuntu 20.04.3 LTS + julia 1.7.1)

I'm not too savvy with the internals of TimeZones/PackageCompiler (TimeZones.jl is actually a dep of a dep for the app I was trying to share) so if I was to venture a guess I'd say, based on the init error occurring on trying to create a directory with a path from the build machine, that it might be related to ~# 357~ ? edit: wrong guess it seems, de-linking the issues

I'm a little dubious that in the 2 years since eb1881a I'd be the first person to hit this problem (but maybe something changed in PackageCompiler since then.. ) -- to be taken with a grain of salt.

Please let me know if you need further clarifications, I'll be glad to help. With regards,

omus commented 2 years ago

Just want to confirm that you're running create_app also on Windows machine?

Felix-Gauthier commented 2 years ago

Yes, I'm running create_app on a Windows machine to relocate to another windows machine.

I did the same thing for the Ubuntu test (ubuntu to ubuntu) that passed.

omus commented 2 years ago

I believe this may have been a corner case that has just slipped through the cracks until now. Typically the directory creation is handled when the package is built. On Windows however we do this directory creation check during package initialization.

I already have a fix for that but I'm doubtful that will fix everything here (if the directory doesn't exist then the required file isn't included in the compiled package).

If you want to give it a try you can using the cv/win-mkdir branch (e.g. ] add TimeZones#cv/win-mkdir)

Felix-Gauthier commented 2 years ago

Thanks! I'll give it a try and let you know.