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

[FR] Do basic checks before compilation

Open bertulli opened this issue 2 years ago • 1 comments

Hi! First, thanks for your work. I tried to compile a sysimage and I ran into a trivial error:

julia> create_sysimage(["Plots", "FFTW"]; sysimage_path="~/Julia/test.so")
✔ [05m:22s] PackageCompiler: compiling incremental system image
ERROR: IOError: mkdir("~"; mode=0o777): permission denied (EACCES)
Stacktrace:
 [1] uv_error
   @ ./libuv.jl:97 [inlined]
 [2] mkdir(path::String; mode::UInt16)
   @ Base.Filesystem ./file.jl:185
 [3] mkpath(path::String; mode::UInt16)
   @ Base.Filesystem ./file.jl:241
 [4] mkpath(path::String; mode::UInt16)
   @ Base.Filesystem ./file.jl:239
 [5] mkpath
   @ ./file.jl:235 [inlined]
 [6] create_sysimg_from_object_file(object_files::Vector{String}, sysimage_path::String; version::Nothing, compat_level::String, soname::Nothing)
   @ PackageCompiler ~/.julia/packages/PackageCompiler/DKijm/src/PackageCompiler.jl:557
 [7] create_sysimage(packages::Vector{String}; sysimage_path::String, project::String, precompile_execution_file::Vector{String}, precompile_statements_file::Vector{String}, incremental::Bool, filter_stdlibs::Bool, cpu_target::String, script::Nothing, sysimage_build_args::Cmd, include_transitive_dependencies::Bool, base_sysimage::Nothing, julia_init_c_file::Nothing, version::Nothing, soname::Nothing, compat_level::String, extra_precompiles::String)
   @ PackageCompiler ~/.julia/packages/PackageCompiler/DKijm/src/PackageCompiler.jl:529
 [8] top-level scope
   @ REPL[10]:1

I assumed Julia would recognize ~ as the home directory. No big problem, but I wondered: in this case, compilation took only about 5 min. In bigger use case, it would be more, and that time is wasted if you have to reissue the command. In basic errors like this (mispelled paths, or permission denied), would it make sense to move these checks before the compilation? In that way, the user could immediately correct the problem, and wait for compilation when they are (reasonably) confident the process will have success.

bertulli avatar Nov 02 '22 17:11 bertulli

Makes sense. Should be fairly easy for someone with the desire to add this

KristofferC avatar Nov 03 '22 13:11 KristofferC