Installing MKL on Windows fails

Installing MKL on a freshly installed Windows 10.0 home fails:

C:\Users\ufechner\tmp>julia --project
               _
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.10.3 (2024-04-30)
 _/ |\__'_|_|_|\__'_|  |  Official https://julialang.org/ release
|__/                   |

(ufechner) pkg> add MKL
    Updating registry at `C:\Users\ufechner\.julia\registries\General.toml`
   Resolving package versions...
   Installed oneTBB_jll ────── v2021.12.0+0
   Installed IntelOpenMP_jll ─ v2024.1.0+0
   Installed MKL_jll ───────── v2024.1.0+0
   Installed MKL ───────────── v0.6.3
  Downloaded artifact: oneTBB
  Downloaded artifact: IntelOpenMP
    Updating `C:\Users\ufechner\Project.toml`
  [33e6dc65] + MKL v0.6.3
    Updating `C:\Users\ufechner\Manifest.toml`
  [33e6dc65] + MKL v0.6.3
  [1d5cc7b8] + IntelOpenMP_jll v2024.1.0+0
  [856f044c] + MKL_jll v2024.1.0+0
  [1317d2d5] + oneTBB_jll v2021.12.0+0
  [4af54fe1] + LazyArtifacts
Precompiling project...
  ✗ MKL_jll
  ✗ MKL
  2 dependencies successfully precompiled in 5 seconds. 91 already precompiled.
  2 dependencies errored.
  For a report of the errors see `julia> err`. To retry use `pkg> precompile`

julia> err
PkgPrecompileError: The following 1 direct dependency failed to precompile:

MKL [33e6dc65-8f57-5167-99aa-e5a354878fb2]

Failed to precompile MKL [33e6dc65-8f57-5167-99aa-e5a354878fb2] to "C:\\Users\\ufechner\\.julia\\compiled\\v1.10\\MKL\\jl_93CA.tmp".
ERROR: LoadError: InitError: could not load library "C:\Users\ufechner\.julia\artifacts\c04d0b3d18e5fcdf696745d217847f2fdcbea1ee\bin\libiomp5md.dll"
The specified module could not be found.
Stacktrace:
  [1] dlopen(s::String, flags::UInt32; throw_error::Bool)
    @ Base.Libc.Libdl .\libdl.jl:117
  [2] dlopen(s::String, flags::UInt32)
    @ Base.Libc.Libdl .\libdl.jl:116
  [3] macro expansion
    @ C:\Users\ufechner\.julia\packages\JLLWrappers\pG9bm\src\products\library_generators.jl:63 [inlined]
  [4] __init__()
    @ IntelOpenMP_jll C:\Users\ufechner\.julia\packages\IntelOpenMP_jll\hZDcv\src\wrappers\x86_64-w64-mingw32.jl:8
  [5] run_module_init(mod::Module, i::Int64)
    @ Base .\loading.jl:1134
  [6] register_restored_modules(sv::Core.SimpleVector, pkg::Base.PkgId, path::String)
    @ Base .\loading.jl:1122
  [7] _include_from_serialized(pkg::Base.PkgId, path::String, ocachepath::String, depmods::Vector{Any})
    @ Base .\loading.jl:1067
  [8] _require_search_from_serialized(pkg::Base.PkgId, sourcepath::String, build_id::UInt128)
    @ Base .\loading.jl:1581
  [9] _require(pkg::Base.PkgId, env::String)
    @ Base .\loading.jl:1938
 [10] __require_prelocked(uuidkey::Base.PkgId, env::String)
    @ Base .\loading.jl:1812
 [11] #invoke_in_world#3
    @ .\essentials.jl:926 [inlined]
 [12] invoke_in_world
    @ .\essentials.jl:923 [inlined]
 [13] _require_prelocked(uuidkey::Base.PkgId, env::String)
    @ Base .\loading.jl:1803
 [14] macro expansion
    @ .\loading.jl:1790 [inlined]
 [15] macro expansion
    @ .\lock.jl:267 [inlined]
 [16] __require(into::Module, mod::Symbol)
    @ Base .\loading.jl:1753
 [17] #invoke_in_world#3
    @ .\essentials.jl:926 [inlined]
 [18] invoke_in_world
    @ .\essentials.jl:923 [inlined]
 [19] require(into::Module, mod::Symbol)
    @ Base .\loading.jl:1746
 [20] include(mod::Module, _path::String)
    @ Base .\Base.jl:495
 [21] top-level scope
    @ C:\Users\ufechner\.julia\packages\JLLWrappers\pG9bm\src\toplevel_generators.jl:192
 [22] include
    @ .\Base.jl:495 [inlined]
 [23] include_package_for_output(pkg::Base.PkgId, input::String, depot_path::Vector{String}, dl_load_path::Vector{String}, load_path::Vector{String}, concrete_deps::Vector{Pair{Base.PkgId, UInt128}}, source::String)
    @ Base .\loading.jl:2222
 [24] top-level scope
    @ stdin:3
during initialization of module IntelOpenMP_jll
in expression starting at C:\Users\ufechner\.julia\packages\MKL_jll\znDzI\src\wrappers\x86_64-w64-mingw32.jl:4
in expression starting at C:\Users\ufechner\.julia\packages\MKL_jll\znDzI\src\MKL_jll.jl:2
in expression starting at stdin:3
ERROR: LoadError: Failed to precompile MKL_jll [856f044c-d86e-5d09-b602-aeab76dc8ba7] to "C:\\Users\\ufechner\\.julia\\compiled\\v1.10\\MKL_jll\\jl_949B.tmp".
Stacktrace:
  [1] error(s::String)
    @ Base .\error.jl:35
  [2] compilecache(pkg::Base.PkgId, path::String, internal_stderr::IO, internal_stdout::IO, keep_loaded_modules::Bool)
    @ Base .\loading.jl:2468
  [3] compilecache
    @ .\loading.jl:2340 [inlined]
  [4] (::Base.var"#968#969"{Base.PkgId})()
    @ Base .\loading.jl:1974
  [5] mkpidlock(f::Base.var"#968#969"{Base.PkgId}, at::String, pid::Int32; kwopts::@Kwargs{stale_age::Int64, wait::Bool})
    @ FileWatching.Pidfile C:\Users\ufechner\.julia\juliaup\julia-1.10.3+0.x64.w64.mingw32\share\julia\stdlib\v1.10\FileWatching\src\pidfile.jl:93
  [6] #mkpidlock#6
    @ C:\Users\ufechner\.julia\juliaup\julia-1.10.3+0.x64.w64.mingw32\share\julia\stdlib\v1.10\FileWatching\src\pidfile.jl:88 [inlined]
  [7] trymkpidlock(::Function, ::Vararg{Any}; kwargs::@Kwargs{stale_age::Int64})
    @ FileWatching.Pidfile C:\Users\ufechner\.julia\juliaup\julia-1.10.3+0.x64.w64.mingw32\share\julia\stdlib\v1.10\FileWatching\src\pidfile.jl:111
  [8] #invokelatest#2
    @ .\essentials.jl:894 [inlined]
  [9] invokelatest
    @ .\essentials.jl:889 [inlined]
 [10] maybe_cachefile_lock(f::Base.var"#968#969"{Base.PkgId}, pkg::Base.PkgId, srcpath::String; stale_age::Int64)
    @ Base .\loading.jl:2983
 [11] maybe_cachefile_lock
    @ .\loading.jl:2980 [inlined]
 [12] _require(pkg::Base.PkgId, env::String)
    @ Base .\loading.jl:1970
 [13] __require_prelocked(uuidkey::Base.PkgId, env::String)
    @ Base .\loading.jl:1812
 [14] #invoke_in_world#3
    @ .\essentials.jl:926 [inlined]
 [15] invoke_in_world
    @ .\essentials.jl:923 [inlined]
 [16] _require_prelocked(uuidkey::Base.PkgId, env::String)
    @ Base .\loading.jl:1803
 [17] macro expansion
    @ .\loading.jl:1790 [inlined]
 [18] macro expansion
    @ .\lock.jl:267 [inlined]
 [19] __require(into::Module, mod::Symbol)
    @ Base .\loading.jl:1753
 [20] #invoke_in_world#3
    @ .\essentials.jl:926 [inlined]
 [21] invoke_in_world
    @ .\essentials.jl:923 [inlined]
 [22] require(into::Module, mod::Symbol)
    @ Base .\loading.jl:1746
 [23] include
    @ .\Base.jl:495 [inlined]
 [24] include_package_for_output(pkg::Base.PkgId, input::String, depot_path::Vector{String}, dl_load_path::Vector{String}, load_path::Vector{String}, concrete_deps::Vector{Pair{Base.PkgId, UInt128}}, source::Nothing)
    @ Base .\loading.jl:2222
 [25] top-level scope
    @ stdin:3
in expression starting at C:\Users\ufechner\.julia\packages\MKL\kCNzy\src\MKL.jl:1
in expression starting at stdin:

Any idea?

Works fine on Linux.

Created a bug report: Installing MKL on Windows fails · Issue #165 · JuliaLinearAlgebra/MKL.jl · GitHub

I checked, the “missing” file exists, but I cannot change into the artifact folder without root permissions…

The file VCRUNTIME140.dll was missing.

Installing https://aka.ms/vs/17/release/vc_redist.x64.exe fixed the issue…