Mac - Cannot launch separate MATLAB application when MATLAB is connected in Visual Studio Code
Issue Description
When I connect to MATLAB in Visual Studio Code and try to open the MATLAB editor, the editor does not launch without any errors. After disconnecting to MATLAB in Visual Studio Code, the editor launch.
Steps to Reproduce
- Open Visual Studio Code
- Connect to MATLAB using the MATLAB extension
- Launch MATLAB editor from Launchpad
Expected Behavior
The MATLAB editor should launch.
Actual Behavior
MATLAB editor does not launch.
System Information
- Operating System: macOS 12.6.3
- Visual Studio Code Version: 1.77.3
- MATLAB Version: R2022b Update 5
- MATLAB Extension Version: v1.0.1
Thank you for reporting this!
Workaround: Launch MATLAB via the terminal. For example -
cd /Applications/MATLAB_R2022b.app/bin
./matlab
or
open -n /Applications/MATLAB_R2022b.app
This seems to be related to a behavior on Mac which attempts to limit the number of MATLAB instances at a time - clicking MATLAB from the Launchpad attempts to focus an existing instance instead of spawning a new one. In this case the active instance is hidden, so it appears that nothing has happened.
We are looking into ways of addressing this.
Yes, this is a problem I've now seen a couple of times myself. Not the Editor specifically, but just MATLAB doesn't open at all on macOS if the VS Code MATLAB extension is connected to a MATLAB. The first couple of times I was really surprised why MATLAB wouldn't start. I hope this can be addressed rather soon, since I will probably be defaulting to using the extension without connection to MATLAB (on macOS) while this is the case.
Thank you for providing the workaround. Launching MATLAB via the terminal has proven to be effective.
I understand that this behavior is specific to Mac and is related to the limitation on the number of MATLAB instances. Clicking MATLAB from the Launchpad tries to focus on an existing instance rather than opening a new one, which results in the active instance being hidden.
I appreciate your efforts in investigating ways to address this bug. Please keep me updated on any progress or potential solutions that may arise.
I wanted to provide an update on this issue: We are actively working to resolve this issue. Because the root cause of this is within MATLAB itself, the fix for this will be tied to a future MATLAB release.
I assume this problem also prevents the desktop feature (mentioned here https://blogs.mathworks.com/matlab/2024/03/05/matlab-extension-for-visual-studio-code-now-with-code-execution/ ) from working on mac?
Hi @afugls - I do not believe there should be a problem with that. This issue should only prevent a new instance of MATLAB to be launched on Mac. However, the desktop command should just display the MATLAB GUI for the instance of MATLAB already connected in VS Code.
If you encounter any issues with this, please let us know!
Hi @afugls - I do not believe there should be a problem with that. This issue should only prevent a new instance of MATLAB to be launched on Mac. However, the
desktopcommand should just display the MATLAB GUI for the instance of MATLAB already connected in VS Code.If you encounter any issues with this, please let us know!
Hi @dklilley - I see that it "works" but maybe not as I expected. That is I want to:
- Open VC Code and a .m file.
- Connect to MATLAB
- Type
desktopin the MATLAB termnial Expected: A MATLAB GUI should appear in the forefront or in the dock. Actual: MATLAB GUI opens in the "background". That is, I can see the GUI if I show all open windows (ctrl+up arrow on Mac), but I cannot, for example, cmd+tab to the GUI or click on it in the dock.
I assume this is because the connected MATLAB instance is hidden as mentioned above. However, it is not a very intuitive behavior (at least not as a first time user).
I see - thank you for the clarification!
Yes, I believe this is a side effect of the MATLAB instance being hidden. Would you mind creating a new issue specifically for this behavior with the desktop command?