mathworks / MATLAB-extension-for-vscode

This extension provides support for editing MATLAB® code in Visual Studio® Code and includes features such as syntax highlighting, code analysis, navigation support, and more.
https://marketplace.visualstudio.com/items?itemName=MathWorks.language-matlab
MIT License
234 stars 15 forks source link

Error in every MATLAB cell "Unable to run code analysis" in VS Code #88

Open tylerlekang opened 8 months ago

tylerlekang commented 8 months ago

System: Windows 10 Conda 23.5.0 Python 3.8.16 matlab-proxy 0.10.0 jupyter-matlab-proxy 0.10.1 Matlab R2023a Update 5

Issue: If I open any existing notebook or make a new notebook and change the cell code type to Matlab, there is an error message displayed saying "Unable to run code analysis. 'file.ipynb' has an invalid file extension"

issue

I have never seen this error before today. This error does not happen in regular editor windows for Matlab .m files, where analysis is run normally and is working fine.

I don't think any code analysis was actually done before in notebooks, but there wasn't an error message either. Really I think that Matlab VS Code extension was just applying the nice syntax highlighting to each cell, and that is still being done.

Possibly something has just been updated in the Matlab VS Code extension? I tried disabling it and re-enabling it, and the error comes right back. EDIT: it seems you cannot run Matlab code cells in VS Code without the Matlab VS Code extension installed and enabled.

I don't understand why they would want such errors to be raised?? Isn't it a perfectly valid use of their extension to run Matlab code in notebook cells?

tylerlekang commented 8 months ago

To clarify: code all runs just as well as before, and the syntax highlighting works just as well as before.

So I can still use it, but the errors are annoying to see now in every cell.

tyePhDCandy commented 8 months ago

Error in every MATLAB cell "Unable to run code analysis" in VS Code

The issue occurs on my vscode in the exactly same way. I also use Matlab 2013 and same plugin setup.

There is also one more issue, if you open multiple sections, and you change contents in any section and press save, all the contents in sections will be the same.

I think the issue is due to updated codes inside matlab plugin.

tyePhDCandy commented 8 months ago

@tylerlekang have you solve the issue? i'm forced to use matlab's mlx file format.

tylerlekang commented 8 months ago

@tyePhDCandy I don't think I have the issue you're referring to, but I'm not sure what you mean by sections. Are you talking about cells within one notebook or do you mean if you open the notebook in multiple splits of the VS Code window, or even in multiple windows?

I agree that I think the issue is with the Matlab VS Code extension. So I'm not sure what can be done about it. I'm hoping @prabhakk-mw may have some internal connections in MW where he can communicate with the Matlab VSC extension team directly about this. Because it does affect the JMP experience in VSC.

And for me the VSC environment is vastly better than the native Jupyter browser environment.

tyePhDCandy commented 8 months ago

@tylerlekang I mean cells within one notebook. if you open multiple cells in one notebook, and you change contents in any cell and press save, all the contents in sections will be changed to the same contents as the first cell.

It seems that the Matlab vs code plugin checks the file extension before linting the codes...

Indeed, VSC env is so much better than native Jupyter env.

I'm forced to use matlab live editor now.

tylerlekang commented 8 months ago

@tyePhDCandy I do not have that problem. I can use the notebook normally as before, but have the error popping up (I believe from the Matlab VSC extension) in every cell, even those without any code.

prabhakk-mw commented 8 months ago

Hi @tylerlekang

I've been able to reproduce the issue as well, and you are right this is originating from the VSCode extension's of the Linter. However, I don't think it is an issue with the extension itself but instead because the MATLAB Linter was not designed for use with files that are not MATLAB specific (.m / .mlx)

I'm moving this issue to the mathworks/matlab-extension-for-vscode repository to drive future support of other file extensions.

prabhakk-mw commented 8 months ago

@tyePhDCandy, I'd recommend opening another issue on this repository with some detailed steps on how to reproduce the issue you are describing, which does seem significantly different from what @tylerlekang is reporting.

tylerlekang commented 6 months ago

Hi @dklilley @prabhakk-mw is there any update on this?

Naïve comment: isn't this just updating [something] so that .m and .ipynb won't throw this error?

EDIT: to clarify, I am not looking for any new features or additional compatibility of Matlab Ext for use with Jupyter Notebooks beyond what it already does provide (which is great!), just for these errors to go away.

Thank you!