Issue with build MKL on Windows 10

I am have issue with build MKL after install MKL.jl (antivirus (Kaspersky) disabled).

(@v1.4) pkg> build MKL
   Building MKL → `J:\Julia_depot\packages\MKL\1edTo\deps\build.log`
┌ Error: Error building `MKL`:
│ Generating precompile statements... 4980 generated in 125.676000 seconds (overhead  91.511079 seconds)
│ [ Info: Splicing in code to load MKL in J:\Julia-1.4.1\bin\..\share\julia\base\sysimg.jl
│ [ Info: getting precompile script from: https://raw.githubusercontent.com/JuliaLang/julia/release-1.4/contrib/generate_precompile.jl
│ [ Info: PackageCompiler: creating base system image (incremental=false)...
│ [ Info: PackageCompiler: creating system image object file, this might take a while...
│ ERROR: LoadError: IOError: unlink: permission denied (EACCES)
│ Stacktrace:
│  [1] uv_error at .\libuv.jl:97 [inlined]
│  [2] unlink(::String) at .\file.jl:888
│  [3] rm(::String; force::Bool, recursive::Bool) at .\file.jl:268
│  [4] rename(::String, ::String) at .\file.jl:899
│  [5] #mv#13 at .\file.jl:393 [inlined]
│  [6] mv at .\file.jl:392 [inlined]
│  [7] move_default_sysimage_if_windows() at J:\Julia_depot\packages\PackageCompiler\xtztx\src\PackageCompiler.jl:83
│  [8] create_sysimage(::Array{Symbol,1}; sysimage_path::Nothing, project::String, precompile_execution_file::Array{String,1}, precompile_statements_file::Array{String,1}, incremental::Bool, filter_stdlibs::Bool, replace_default::Bool, cpu_target::String, script::String, base_sysimage::Nothing, isapp::Bool) at J:\Julia_depot\packages\PackageCompiler\xtztx\src\PackageCompiler.jl:439
│  [9] top-level scope at J:\Julia_depot\packages\MKL\1edTo\src\install.jl:107
│  [10] eval at .\boot.jl:331 [inlined]
│  [11] change_blas_library(::String) at J:\Julia_depot\packages\MKL\1edTo\src\install.jl:105
│  [12] enable_mkl_startup() at J:\Julia_depot\packages\MKL\1edTo\src\install.jl:82
│  [13] top-level scope at J:\Julia_depot\packages\MKL\1edTo\deps\build.jl:5
│  [14] include(::String) at .\client.jl:439
│  [15] top-level scope at none:5
│ in expression starting at J:\Julia_depot\packages\MKL\1edTo\deps\build.jl:5
└ @ Pkg.Operations D:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.4\Pkg\src\Operations.jl:892

julia> versioninfo()
Julia Version 1.4.1
Commit 381693d3df* (2020-04-14 17:20 UTC)
Platform Info:
  OS: Windows (x86_64-w64-mingw32)
  CPU: Intel(R) Core(TM) i7-3770K CPU @ 3.50GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-8.0.1 (ORCJIT, ivybridge)
Environment:
  JULIA_DEPOT_PATH = J:\Julia_depot
1 Like

Looks like a permission error.
An easy thing to try is run Julia as Administrator.

1 Like

I don’t think it is a recommended solution.
Why, in order to install package, one would need elevated privileges?
It seems @Andrei_Bobrov doesn’t even try to install it into a system path. Why would he need Admin rights?

The issue is that the default sysimage is supposed to be replaced but on windows moving/deleting files that are in use is pretty problematic. The code right now moves the existing sysimage and then adds the new one in its place which has worked for me but apparently it doesn’t work all the time.

@RoyiAvital is right - the same problem.

@kristoffer.carlsson, Maybe the solution is like how Operating Systems updates work.
They schedule the file replacement to the next restart.
So maybe you could insert the operations to replace System Image to the ext loading of Julia?
Does Julia have something, which is user configurable, to run before it loads Sys Image?