MATLAB "escape" function doesn't work with mamba-installed packages like GMT and gfortran

Hi all,

I am having some new issues with trying to use the ‘escape’ function ‘!’ of MATLAB to call external scripts that depend upon code I’ve installed with miniforge3/mamba, like GMT, pyGMT, and the gfortran compiler. I am using a new Mac Studio that I have set up in the last 6 months or so.

In the past, I have been able to use the escape command to do this quite easily, with installs via conda of GMT, pyGMT, and gfortran, on Macs with both Intel and M-series processors, but in the last month or so I have been running into problems.

Here is some output from a MATLAB script that attempts to call a GMT (version 6) script using the escape function:

gmt: Command not found.
gmt: Command not found.
-E172.6422/0.0/55.3088
gmt: Command not found.
awk: write error on /dev/stdout

Using the escape function on gmt scripts used to work just fine, but now MATLAB can’t find my install of gmt from miniforge3.

Another thing I do a lot is call FORTRAN programs from MATLAB. Here is the problem I’m having with that (I’ve redacted my home directory to “~”):

awk: write error on /dev/stdout
input record number 688, file ~/calculations/PlutoCalc/SegmentFiles/SputnikAzimuthal_FeatureVertices_p.txt
source line number 1
dyld[27489]: Library not loaded: @rpath/libgfortran.5.dylib
Referenced from: ~/calculations/flexure/rad2008/code/broflex2astu
Reason: tried: ‘~/miniforge3/envs/gf/lib/libgfortran.5.dylib’ (duplicate LC_RPATH ‘@loader_path’), ‘/System/Volumes/Preboot/Cryptexes/OS/~/miniforge3/envs/gf/lib/libgfortran.5.dylib’ (no such file), ‘~/calculations/flexure/rad2008/code/libgfortran.5.dylib’ (no such file), ‘~/miniforge3/envs/gf/lib/gcc/arm64-apple-darwin20.0.0/13.2.0/libgfortran.5.dylib’ (no such file),

…and a bunch more, ending with:

~/calculations/flexure/rad2008/code/broflex2astu: Aborted

It appears the fundamental problem is that MATLAB does not know where to look for the gmt executables or FORTRAN libraries. The latter puzzles me, since the program I’m calling has already been compiled, and therefore I would just expect it to work when called. And I get the same type of error when I try to run the FORTRAN executable.

My first guess is that there is some .something configuration file that is missing, that points to the directories where the gmt, pyGMT, and FORTRAN are. I’m wondering if the following error message that shows up on my terminals:

Last login: Wed May 14 11:44:01 on console
Error unknown MAMBA_EXE: “”, filename must be mamba or micromamba

And I thought I saw something about how a recent update of mamba or something else requires some attention to some files. I can’t remember where I saw that.

Maybe using mamba is a dumb idea and I should go back to conda?

Another potential issue here is that I create environments for the pyGMT (which includes GMT) and gfortran installs. Does that mean I have to get MATLAB into those environments somehow? It didn’t used to be that way, and I think it still isn’t: I tried opening MATLAB from within my pyGMT environment and it still gave the same errors.

Anyway, thanks in advance for any advice you could give me.

Sincerely,
Pat

PS this is not a question about MATLAB-GMT interfaces. I’m only interested in recovering my previous ability to use the escape functionality of MATLAB.

Alright, I’ve managed to solve the gfortran problem just by uninstalling and reinstalling gfortran within my “gf” mamba-created environment. Simple!

When I next get some free time, I’ll try the same with my pygmt environment. (I’m running too many models using that escape function at the moment!)

Best,
Pat