matlab-actions / setup-matlab

Set up your GitHub Actions workflow with a specific version of MATLAB.
BSD 3-Clause "New" or "Revised" License
77 stars 12 forks source link

setup-matlab v2-beta failed on windows runners #60

Closed fangq closed 1 year ago

fangq commented 1 year ago

I want to first thank the team for making matlab available for github actions.

I noticed that setup-matlab v2-beta supports all platforms as opposed to Linux-only for v1, and used it for building a mex file for one of my toolboxes. For Mac and Linux, it runs fine, but it failed for the windows runner (windows-2019), see error log here

https://github.com/fangq/mmc/actions/runs/4395905754/jobs/7698013664

the error message (Error: Unable to complete installation setup) is not explicit and I don't really what had caused this.

is there a way to find out and get around?

I also noticed that v2 takes significantly longer time (3-7 min on all tested platforms) than v1 on Linux (~20 s). see

https://github.com/fangq/mmc/actions/runs/4398123809/usage

I am wondering if this is expected, and if there is anyway to reduce this setup overhead. I need mex and the libraries for my project.

fangq commented 1 year ago

one other observation:

I initially thought that if the setup overhead is a result of larger installation files, using an older release, for example R2020a, may result in faster run-time.

interestingly, it turned out to be the opposite - after running for 20 min, setting up R2020a was still going, so I had to terminate the run, see

https://github.com/fangq/mmc/actions/runs/4394455692/usage

was the v2-beta optimized on R2022 compared to R2020?

mcafaro commented 1 year ago

There is a known issue with windows-2019 and setup-matlab@v2-beta with R2022b. We are looking into it.

A few possible workarounds:

setup-matlab v1 and v2 work in different ways. The set up in v2 generally takes longer but the execution of MATLAB will be faster. As you noted, v2 is optimized with more recent versions of MATLAB.

fangq commented 1 year ago

@mcafaro thanks for your helpful comments! I did not know v1 also supports mac and windows. I just tested it and setup-matlab@v1 indeed works. I do not need toolboxes, so this is perfect for me.

however, I am getting another issue: the mex command (as a shell utility) worked nicely for both Linux and Mac, but it failed for windows, complaining "which: no mex in (/mingw64/bin:/usr/bin:/c/Users/runneradmin/bin:/c/Program Files/matlab-batch:/c/Program Files/MATLAB/R2022b/bin:....", see full log here:

https://github.com/fangq/mmc/actions/runs/4406708139/jobs/7719330338

what is the correct path I should add to make mex work on windows? thanks again

mcafaro commented 1 year ago

Depending on the shell you are using in Windows, you may need to call "mex.bat" instead of just "mex" to run the mex command from a system terminal.

fangq commented 1 year ago

I think I am one step away from completely solving this.

as you can see form my above 4 new commits, I had trouble telling MATLAB where to find gcc compiler (MW_MINGW64_LOC) on the windows runner. The runner's default gcc is installed by mingw64 located in C:\ProgramData\Chocolatey\lib\mingw\tools\install\mingw64\, however, no matter how I set this env variable (and confirm it is correctly set), MATLAB insists on resetting MW_MINGW64_LOC to C:/msys64/usr/ and ignores my desired path. Because of that, mex could not find the gcc already installed.

is there a way to tell MATLAB to take the MW_MINGW64_LOC setting from the environment?

mcafaro commented 1 year ago

I do not think your env variables are making it to the location where mex is being called (in Make).

See this simple demo workflow where I call mex directly and confirm that an MW_MINGW64_LOC env var is recognized.

fangq commented 1 year ago

I was able to get everything to work on windows. it turned out the MW_MINGW64_LOC issue was because of my hard-coded setting inside my makefile. after fixing it, it was set properly.

I am quite happy that setup-matlab@v1 works on all 3 platforms. Thanks @mcafaro for your help. feel free to close this issue.

mcafaro commented 1 year ago

Glad to hear it is working for you.