Getting MATLAB.jl on Windows to work

Hello everyone, I raised an issue on the GitHub repo but looks like it’s not very active so just wanted to see if anyone else had this problem and a fix.

I’ve added MATLAB in Julia v1.11 through the package manager. I am running Windows 11 and MATLAB 2024b is installed. When I run

using MATLAB  # this is fine
mat"ver"

or any other MATLAB code in VSCode, I get:

The terminal process "C:\Users\testacct\.julia\juliaup\julia-1.11.2+0.x64.w64.mingw32\bin\julia.exe '-i', '--banner=no', '--project=C:\Users\testacct\.julia\environments\v1.11', 'c:\Users\testacct\.vscode\extensions\julialang.language-julia-1.127.2\scripts\terminalserver\terminalserver.jl', '\\.\pipe\vsc-jl-repl-159c2360-275d-4eda-9708-5697120d6478', '\\.\pipe\vsc-jl-repldbg-34439aaa-b352-4163-8607-b71adecda219', '\\.\pipe\vsc-jl-cr-929cae24-af6b-48c7-a83a-58fad01bbf68', 'USE_REVISE=true', 'USE_PLOTPANE=true', 'USE_PROGRESS=true', 'ENABLE_SHELL_INTEGRATION=true', 'DEBUG_MODE=false'" terminated with exit code: -529697949.

When running just the Julia terminal without VSCode, the terminal just closes. However, I have noticed that the MATLAB Command Window will pop up before exiting.

When I test the build:

(@v1.11) pkg> test MATLAB
     Testing MATLAB
      Status `C:\Users\testacct\AppData\Local\Temp\jl_tkJSKc\Project.toml`
  [10e44e05] MATLAB v0.8.4
  [8f399da3] Libdl v1.11.0
  [2f01184e] SparseArrays v1.11.0
  [8dfed614] Test v1.11.0
      Status `C:\Users\testacct\AppData\Local\Temp\jl_tkJSKc\Manifest.toml`
  [10e44e05] MATLAB v0.8.4
  [56f22d72] Artifacts v1.11.0
  [2a0f44e3] Base64 v1.11.0
  [b77e0a4c] InteractiveUtils v1.11.0
  [8f399da3] Libdl v1.11.0
  [37e2e46d] LinearAlgebra v1.11.0
  [56ddb016] Logging v1.11.0
  [d6f4376e] Markdown v1.11.0
  [9a3f8284] Random v1.11.0
  [ea8e919c] SHA v0.7.0
  [9e88b42a] Serialization v1.11.0
  [2f01184e] SparseArrays v1.11.0
  [8dfed614] Test v1.11.0
  [e66e0078] CompilerSupportLibraries_jll v1.1.1+0
  [4536629a] OpenBLAS_jll v0.3.27+1
  [bea87d4a] SuiteSparse_jll v7.7.0+0
  [8e850b90] libblastrampoline_jll v5.11.0+0
     Testing Running tests...
┌ Error: mktempdir cleanup
│   exception =
│    IOError: rm("C:\\Users\\TESTACCT\\AppData\\Local\\Temp\\jl_tkJSKc"): directory not empty (ENOTEMPTY)
│    Stacktrace:
│      [1] uv_error
│        @ .\libuv.jl:106 [inlined]
│      [2] rm(path::String; force::Bool, recursive::Bool)
│        @ Base.Filesystem .\file.jl:307
│      [3] rm
│        @ .\file.jl:273 [inlined]
│      [4] mktempdir(fn::Pkg.Operations.var"#116#121"{Dict{String, Any}, Bool, Bool, Bool, Pkg.Operations.var"#131#136"{Bool, Cmd, Cmd, Nothing, Pkg.Types.Context, Vector{Tuple{String, Base.Process}}, String, Pkg.Types.PackageSpec}, Pkg.Types.Context, Pkg.Types.PackageSpec, String, String}, parent::String; prefix::String)
│        @ Base.Filesystem .\file.jl:825
│      [5] mktempdir(fn::Function, parent::String)
│        @ Base.Filesystem .\file.jl:815
│      [6] mktempdir
│        @ .\file.jl:815 [inlined]
│      [7] #sandbox#115
│        @ C:\Users\testacct\.julia\juliaup\julia-1.11.2+0.x64.w64.mingw32\share\julia\stdlib\v1.11\Pkg\src\Operations.jl:1834 [inlined]   
│      [8] test(ctx::Pkg.Types.Context, pkgs::Vector{Pkg.Types.PackageSpec}; coverage::Bool, julia_args::Cmd, test_args::Cmd, test_fn::Nothing, force_latest_compatible_version::Bool, allow_earlier_backwards_compatible_versions::Bool, allow_reresolve::Bool)
│        @ Pkg.Operations C:\Users\testacct\.julia\juliaup\julia-1.11.2+0.x64.w64.mingw32\share\julia\stdlib\v1.11\Pkg\src\Operations.jl:2052
│      [9] test
│        @ C:\Users\testacct\.julia\juliaup\julia-1.11.2+0.x64.w64.mingw32\share\julia\stdlib\v1.11\Pkg\src\Operations.jl:1996 [inlined]   
│     [10] test(ctx::Pkg.Types.Context, pkgs::Vector{Pkg.Types.PackageSpec}; coverage::Bool, test_fn::Nothing, julia_args::Cmd, test_args::Cmd, force_latest_compatible_version::Bool, allow_earlier_backwards_compatible_versions::Bool, allow_reresolve::Bool, kwargs::@Kwargs{io::IOContext{IO}})
│        @ Pkg.API C:\Users\testacct\.julia\juliaup\julia-1.11.2+0.x64.w64.mingw32\share\julia\stdlib\v1.11\Pkg\src\API.jl:475
│     [11] test(pkgs::Vector{Pkg.Types.PackageSpec}; io::IOContext{IO}, kwargs::@Kwargs{})
│        @ Pkg.API C:\Users\testacct\.julia\juliaup\julia-1.11.2+0.x64.w64.mingw32\share\julia\stdlib\v1.11\Pkg\src\API.jl:159
│     [12] test(pkgs::Vector{Pkg.Types.PackageSpec})
│        @ Pkg.API C:\Users\testacct\.julia\juliaup\julia-1.11.2+0.x64.w64.mingw32\share\julia\stdlib\v1.11\Pkg\src\API.jl:148
│     [13] do_cmd(command::Pkg.REPLMode.Command, io::Base.TTY)
│        @ Pkg.REPLMode C:\Users\testacct\.julia\juliaup\julia-1.11.2+0.x64.w64.mingw32\share\julia\stdlib\v1.11\Pkg\src\REPLMode\REPLMode.jl:407
│     [14] do_cmds(commands::Vector{Pkg.REPLMode.Command}, io::Base.TTY)
│        @ Pkg.REPLMode C:\Users\testacct\.julia\juliaup\julia-1.11.2+0.x64.w64.mingw32\share\julia\stdlib\v1.11\Pkg\src\REPLMode\REPLMode.jl:393
│     [15] do_cmds(repl::REPL.LineEditREPL, commands::String)
│        @ REPLExt C:\Users\testacct\.julia\juliaup\julia-1.11.2+0.x64.w64.mingw32\share\julia\stdlib\v1.11\Pkg\ext\REPLExt\REPLExt.jl:92  
│     [16] on_done(s::REPL.LineEdit.MIState, buf::IOBuffer, ok::Bool, repl::REPL.LineEditREPL)
│        @ REPLExt C:\Users\testacct\.julia\juliaup\julia-1.11.2+0.x64.w64.mingw32\share\julia\stdlib\v1.11\Pkg\ext\REPLExt\REPLExt.jl:106 
│     [17] #invokelatest#2
│        @ .\essentials.jl:1055 [inlined]
│     [18] invokelatest
│        @ .\essentials.jl:1052 [inlined]
│     [19] (::REPLExt.var"#47#50"{REPL.LineEditREPL})(s::REPL.LineEdit.MIState, buf::IOBuffer, ok::Bool)
│        @ REPLExt C:\Users\testacct\.julia\juliaup\julia-1.11.2+0.x64.w64.mingw32\share\julia\stdlib\v1.11\Pkg\ext\REPLExt\REPLExt.jl:128 
│     [20] #invokelatest#2
│        @ .\essentials.jl:1055 [inlined]
│     [21] invokelatest
│        @ .\essentials.jl:1052 [inlined]
│     [22] run_interface(terminal::REPL.Terminals.TextTerminal, m::REPL.LineEdit.ModalInterface, s::REPL.LineEdit.MIState)
│        @ REPL.LineEdit C:\Users\testacct\.julia\juliaup\julia-1.11.2+0.x64.w64.mingw32\share\julia\stdlib\v1.11\REPL\src\LineEdit.jl:2755
│     [23] run_frontend(repl::REPL.LineEditREPL, backend::REPL.REPLBackendRef)
│        @ REPL C:\Users\testacct\.julia\juliaup\julia-1.11.2+0.x64.w64.mingw32\share\julia\stdlib\v1.11\REPL\src\REPL.jl:1474
│     [24] (::REPL.var"#75#81"{REPL.LineEditREPL, REPL.REPLBackendRef})()
│        @ REPL C:\Users\testacct\.julia\juliaup\julia-1.11.2+0.x64.w64.mingw32\share\julia\stdlib\v1.11\REPL\src\REPL.jl:480
└ @ Base.Filesystem file.jl:828
ERROR: Package MATLAB errored during testing (exit code: 3765269347)

After testing I have checked “C:\Users\TESTACCT\AppData\Local\Temp\jl_tkJSKc” and it appears to be empty.

I believe this gentleman had the same error and suggested running the Julia terminal in Administrator mode for installation and testing.

Having tried this I got no change in the outcome. Still same error in my case.

Many thanks if you can suggest something else to try.

I skim through your issues related to MATLAB.jl, I am wondering if there is a general pause solution to Julia packaging on Windwos? I ran into similar problem just updating packages, it tried to rm anon-empty temp directory, by the time I navigate to the location it appears to be empty.

As far as I understood, MATLAB.jl only reliably supports versions up to Matlab R2022a.

I’ve been using MATLAB.jl without issues on Windows 11 with R2024b using both Julia v1.10 and v1.11.

Sounds like MATLAB.jl might not be handling the COM interface well on Windows 11. I had a similar issue. Running Julia and VSCode as admin helped a bit, but switching to Julia’s REPL outside VSCode finally did the trick. Also, double-check MATLAB’s path in ENV["MATLAB_HOME"].