# Getting MATLAB.jl on Windows to work

**URL:** <https://discourse.julialang.org/t/getting-matlab-jl-on-windows-to-work/124575>\
**Category:** General Usage\
**Tags:** package, interoperability, matlab\
**Created:** [January 9, 2025, 10:35am UTC](https://discourse.julialang.org/t/getting-matlab-jl-on-windows-to-work/124575 "2025-01-09T10:35:45Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![hatmatrix](https://avatars.discourse-cdn.com/v4/letter/h/5f8ce5/32.png) [@hatmatrix](https://discourse.julialang.org/u/hatmatrix)\
**Post date:** [January 9, 2025, 10:35am UTC](https://discourse.julialang.org/t/getting-matlab-jl-on-windows-to-work/124575/1 "2025-01-09T10:35:46Z")

</div>

Hello everyone, I raised [an issue](https://github.com/JuliaInterop/MATLAB.jl/issues/230) 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

```julia
using MATLAB # this is fine
mat"ver"

```

or any other MATLAB code in VSCode, I get:

```julia
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:

```julia
(@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.

- [https://discourse.julialang.org/t/what-did-i-do-wrong-when-installing-my-matlab-jl-package/73546/6](https://discourse.julialang.org/t/what-did-i-do-wrong-when-installing-my-matlab-jl-package/73546/6)
- [https://stackoverflow.com/a/72183952/](https://stackoverflow.com/a/72183952/)

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.

---

<div class="post-metadata">

**Author:** ![cchderrick](https://avatars.discourse-cdn.com/v4/letter/c/ecd19e/32.png) [@cchderrick](https://discourse.julialang.org/u/cchderrick)\
**Post date:** [April 9, 2025, 5:08pm UTC](https://discourse.julialang.org/t/getting-matlab-jl-on-windows-to-work/124575/2 "2025-04-09T17:08:20Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![DNF](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dnf/32/10191_2.png) [@DNF](https://discourse.julialang.org/u/DNF)\
**Post date:** [April 9, 2025, 5:14pm UTC](https://discourse.julialang.org/t/getting-matlab-jl-on-windows-to-work/124575/3 "2025-04-09T17:14:14Z")

</div>

> [@hatmatrix](#):
>
> MATLAB 2024b is installed.

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

---

<div class="post-metadata">

**Author:** ![stillyslalom](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stillyslalom/32/45687_2.png) [@stillyslalom](https://discourse.julialang.org/u/stillyslalom)\
**Post date:** [April 9, 2025, 6:48pm UTC](https://discourse.julialang.org/t/getting-matlab-jl-on-windows-to-work/124575/4 "2025-04-09T18:48:11Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![OStebbins](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ostebbins/32/215850_2.png) [@OStebbins](https://discourse.julialang.org/u/OStebbins)\
**Post date:** [April 10, 2025, 11:08am UTC](https://discourse.julialang.org/t/getting-matlab-jl-on-windows-to-work/124575/5 "2025-04-10T11:08:00Z")

</div>

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"]`.

---

<div class="post-metadata">

**Author:** ![hatmatrix](https://avatars.discourse-cdn.com/v4/letter/h/5f8ce5/32.png) [@hatmatrix](https://discourse.julialang.org/u/hatmatrix)\
**Post date:** [April 28, 2025, 8:41pm UTC](https://discourse.julialang.org/t/getting-matlab-jl-on-windows-to-work/124575/6 "2025-04-28T20:41:10Z")

</div>

You’re right - the repository does give a warning about MATLAB versions after R2022.
