Failed to open file '...\mcr\toolbox\matlab\iofun\@timer\timer.m'. Details: 'File stream is closed. The following flags are set: failbit.' when using plot in standalone exe
26 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
My standalone application (executable file on Windows 10) works well in performing a variety of task: reading and writing files, executing third party software, make computations, plot charts, log diary, move files, etc. I also need to show the console during execution as it reports a diary of the operations performed, warnings, and some output data.
The final output data are a few lines on the console and a plot. The console is intended to reproduce the same output of the MATLAB command window. However, any time the mouse pointer is hovering on the plot generated by the standalone executable, the command line throws a long sequence of errors:
Failed to open file 'C:\Program Files\MATLAB\MATLAB Runtime\R2022b\mcr\toolbox\matlab\iofun\@timer\timer.m'. Details: 'File stream is closed. The following flags are set: failbit.'
Failed to open file 'C:\Program Files\MATLAB\MATLAB Runtime\R2022b\mcr\toolbox\matlab\iofun\@timer\timer.m'. Details: 'File stream is closed. The following flags are set: failbit.'
Failed to open file 'C:\Program Files\MATLAB\MATLAB Runtime\R2022b\mcr\toolbox\matlab\iofun\@timer\timer.m'. Details: 'File stream is closed. The following flags are set: failbit.'
Warning: Error occurred while executing the listener callback for event WindowMouseMotion defined for class matlab.ui.Figure:
The file
"C:\Program Files\MATLAB\MATLAB Runtime\R2022b\mcr\toolbox\matlab\iofun\@timer\timer.m"
cannot be executed.
Error in matlab.graphics.interaction.actions.Linger/startTimer
Error in matlab.graphics.interaction.actions.Linger/motionCallback
Error in matlab.graphics.interaction.actions.Linger
> In waitforallfiguresclosed (line 20)
Failed to open file 'C:\Program Files\MATLAB\MATLAB Runtime\R2022b\mcr\toolbox\matlab\iofun\@timer\timer.m'. Details: 'File stream is closed. The following flags are set: failbit.'
Failed to open file 'C:\Program Files\MATLAB\MATLAB Runtime\R2022b\mcr\toolbox\matlab\iofun\@timer\timer.m'. Details: 'File stream is closed. The following flags are set: failbit.'
Failed to open file 'C:\Program Files\MATLAB\MATLAB Runtime\R2022b\mcr\toolbox\matlab\iofun\@timer\timer.m'. Details: 'File stream is closed. The following flags are set: failbit.'
Failed to open file 'C:\Program Files\MATLAB\MATLAB Runtime\R2022b\mcr\toolbox\matlab\iofun\@timer\timer.m'. Details: 'File stream is closed. The following flags are set: failbit.'
Failed to open file 'C:\Program Files\MATLAB\MATLAB Runtime\R2022b\mcr\toolbox\matlab\iofun\@timer\timer.m'. Details: 'File stream is closed. The following flags are set: failbit.'
Failed to open file 'C:\Program Files\MATLAB\MATLAB Runtime\R2022b\mcr\toolbox\matlab\iofun\@timer\timer.m'. Details: 'File stream is closed. The following flags are set: failbit.'
Failed to open file 'C:\Program Files\MATLAB\MATLAB Runtime\R2022b\mcr\toolbox\matlab\iofun\@timer\timer.m'. Details: 'File stream is closed. The following flags are set: failbit.'
Failed to open file 'C:\Program Files\MATLAB\MATLAB Runtime\R2022b\mcr\toolbox\matlab\iofun\@timer\timer.m'. Details: 'File stream is closed. The following flags are set: failbit.'
Failed to open file 'C:\Program Files\MATLAB\MATLAB Runtime\R2022b\mcr\toolbox\matlab\iofun\@timer\timer.m'. Details: 'File stream is closed. The following flags are set: failbit.'
Failed to open file 'C:\Program Files\MATLAB\MATLAB Runtime\R2022b\mcr\toolbox\matlab\iofun\@timer\timer.m'. Details: 'File stream is closed. The following flags are set: failbit.'
Failed to open file 'C:\Program Files\MATLAB\MATLAB Runtime\R2022b\mcr\toolbox\matlab\iofun\@timer\timer.m'. Details: 'File stream is closed. The following flags are set: failbit.'
Failed to open file 'C:\Program Files\MATLAB\MATLAB Runtime\R2022b\mcr\toolbox\matlab\iofun\@timer\timer.m'. Details: 'File stream is closed. The following flags are set: failbit.'
Warning: Error occurred while executing the listener callback for event ButtonExited defined for class matlab.graphics.primitive.canvas.JavaCanvas:
The file
"C:\Program Files\MATLAB\MATLAB Runtime\R2022b\mcr\toolbox\matlab\iofun\@timer\timer.m"
cannot be executed.
This happened on R2022b on different machines with Windows 10. The exe provides the same results of the MATLAB script and everything works fine, except for the errors reported above. I tried to disable the interactivity of the plot, avoid moving files, using a different type of the plot: the issue is always present.
Due to the complexity and the confidentiality of my work I will report a minimum and generic working example that provides the same issue. It is sufficient to generate the executable file of the following code with the Application Compiler:
close all; clearvars; clc
A = magic(5);
plot(A,'o-')
grid on
title('Call it magic')
with the additional runtime setting "Do not display the Windows Command Shell..." disabled. I get something like the following screenshot.
Any advice on how to solve?
3 Commenti
Eric Delgado
il 5 Mag 2024
Wow... I have the same issue, but in Matlab WebServer environment (which is supported by Matlab Runtime). :(
Hey guys, did you already open a request for service so MathWorks can respond to what is happening?
Risposte (2)
Ganesh
il 14 Set 2023
The issue is non reproducible from my end, and may have to do with version mismatches of of MATLAB Runtime.
Feel free to reach out if the issue still persists.
Thanks and Regards,
Ganesh S
CM
il 23 Ago 2024
I am getting the same problem. I am using R2023b. It is not and MCR issue. I am running the exe on the same PC it is compiled on, which I think means it is using the installed matlab instead of MCR.
It happens when the exe tries to load a mat file. It does not happen when I run the script in matlab.
Some curious observations that might help you track this down:
I wrote my own file name obfuscation script, because the inbuilt conflicted with one of the hardware drivers I used. I only get the problem if I compile with the obfuscated file names.
The error occurs on loading a mat file.
The missing files have the non-obfuscated names and paths. So there must be a reference to those names and paths in the loaded mat file. But I cannot find them and I am not sure why merely loading the mat file would trigger matlab to go looking for thos code files.
Also:
I tried reproducing everything from scratch. The issue only occurs if I generate the mat file by running the script in matlab, and open it with a compiled app. So probably not an issue for me, luckily, except that one of the files that trigger the problem I want to make available to my users. Also, this time round I got a different set of errors, but for the same set of files. The errors I got are:
The file
'C:\path\file.m'
is not in the application's expanded CTF archive at
'C:\Users\user\AppData\Local\Temp\user\mcrCache23.2\App10'.
This is typically caused by calls to ADDPATH in your startup.m or matlabrc.m files. Please see the compiler documentation and use the ISDEPLOYED function to ensure ADDPATH commands are not executed by deployed applications.
As far as I can tell, my app does not use addpath.
The missing files are not callback functions.
1 Commento
CM
il 24 Ago 2024
I had a bit more of a play around with it, and it appears to be something wrong with the mat file. If I load it into matlab and save the variables to a mat file again, that fixes the mat file. Which is a good enough workaround for me. I can email the original file with the issue to the matlab developers if you are interested.
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!