Using MATLAB Package with R2022b and R2021b downloaded


I am trying to use the MATLAB package, which I have read has a bug with both the R2022a and R2022b Matlab versions. I have R2021b installed, but when I attempt to build the package, it returns an error because it recognizes the copy of R2022b. On my other device, where I only have R2021b installed, it works fine. I still use Matlab for other purposes, so I need to keep a copy of the most recent version for that. Is there a way I can tell Julia to “look past” the R2022b copy of Matlab and find the R2021b copy? Or must I uninstall R2022b to make this work?


Probably you must change the search order in your path such that R2021b is found first.

1 Like

How would I do that? Sorry, I am quite new to this language

That’s not a Julia operation. You’d do that on OS side (Windows? Search the web on how to change the path)

It’s not Windows, I have a Mac.

Don’t remember how Matlab installs on Mac and how it gets found. Maybe it’s in your .profile or .bashrc. Where paths are declared. Sorry, you’ll to find that out (or some Macker helps you).

Going off the MATLAB.jl readme, you could try

pkg> rm MATLAB
julia> ENV["MATLAB_ROOT"] = "/Applications/"
pkg> add MATLAB

Replace the right-hand side with the path to your MATLAB app path if it’s different (you can click on the app and do Option-Command-C to copy the path to clipboard).


Thank you! This worked in the sense that it now recognized R2021b, but I am now getting another error. It says LoadError: could not load library “/Applications/”
dlopen(/Applications/, 1): no suitable image found.

Do you know what that means?

It means that the path to the library file that it thinks should be there
is not actually there. It don’t have MATLAB installed, so not sure why this is the case, but you can check whether you can follow the path in the Finder or Terminal to find out where it’s different.

I apologize, please bare with me. I am not very good with computer-related stuff. The idea of “path” is new to me from installing Julia. It took me forever to simply add Julia to the executable path because I don’t know anything about it.

How would I “follow the path” to see what is in Finder or Terminal? Also, what should I expect to add in order to make it work? Would I already have the needed file installed? I should mention that Matlab is working fine on my computer.

Did you manage to do this?

When you run a command from the terminal, the operating system doesn’t automatically know where the program is located in the file system. It has a list of directories where it can look. If it’s not in one of those, you get an error (command not found or something). So if you install a new program (like Julia or Python or something) you have to add it to this list of directories (or PATH) so that the OS can find it.

If you search for how to change your PATH on macOS, there are a quite a few articles. Here are a couple articles I found with more details:

I’m afraid the problem is way more complicated than a simple path adjustment. We had lots of problems like this with GMT MEX toolbox. The problem is that Mathworks shipped very old versions of some common used shared libs (netCXDF for example) and then they conflicted with those of the programs calling the Matlab libs. I’m not saying that’s what is happening here but hell smells a lot like it. The only way that I know of to track this is to use otool -L called on the program that has Matlab libs dependencies and see what comes out.

(post deleted by author)

Yes, I was able to replace the path. It now finds R2021b. For what it’s worth, I have deleted R2022b entirely as I can run everything I need to at the moment on R2021b. The issue remains. I did this that way we don’t have to worry about the other version potentially causing any issue.

I mentioned in a reply to a different comment that I believe this is a Mac-only issue. On my Windows laptop with only R2021b installed, I had no issues using MATLAB.jl. Everything worked as intended with no need to change anything. I’m not sure if that helps, but it’s either an issue with the way OSX reads Matlab or an issue with the Mac version of MATLAB itself.

Perhaps this is the case, but I really don’t think it is. I had no issues using MATLAB.jl on my laptop, which only had R2021b installed. Now, out of curiosity, I have deleted R2022b from my current desktop that I hope to use, and the issue persisted. My laptop is Windows and my desktop is a Mac. If it was an issue of Matlab including old files, then the Windows version should have also had the same problem. Unless the Windows version of Matlab is more refined and doesn’t have the problem? I think this is somehow a Mac issue, but I’m so bad with computers in general that I can safely say I don’t have the capability to figure it out.

Not necessarily. Unix is way more terrible with shared libs incompatibilities than Windows.

I see now, the error said “no suitable image found.”

  1. Can you post the full error message?
  2. Can you say what macOS version you have?
  3. Can you open Terminal, run this, and post the output?
dyld_info -platform  /Applications/

I’m wondering if there is an incompatibility here with your OS version.

Yes, that’s right. It’s to do with the way macOS is trying to work with the MATLAB code.