No log file generated for standalone app

12 visualizzazioni (ultimi 30 giorni)
Michael
Michael il 7 Lug 2021
Risposto: Michael il 16 Lug 2021
I am on macOS Catalina trying to deploy a standalone Matlab app using the application compliler. I am on R2020b.
I check off the 'Create log file' option in the Application Compiler and provide a filename that complies with the special character requirements. When I try running my app, I don't ever see a log file generated. I have tried running it after installing it, from the 'for_testing' folder, and from the 'for_redistribution_files_only' folders with no success. My problem is that I am getting errors in my app when deployed as an application, but not when run within appdesigner. Without the log file, I can't debug.
What am I doing wrong? Thanks.
  6 Commenti
Michael
Michael il 9 Lug 2021
I was wondering the same thing myself with regard to file write premissions. I might need to submit a bug ticket to Mathworks if I can't get this figured out soon.
Michael
Michael il 9 Lug 2021
Modificato: Michael il 9 Lug 2021
Just got in touch with Mathworks support about this. If you run the application via Terminal by navigating to the application folder and using the terminal command
./run_<your_app_filename>.sh <matlab_runtime_directory path>
he log file will generate properly.
Mathworks support is looking to this issue, trying to figure out why starting the app with a double click on the icon doesn't generate a log file. I'll post back here if they are able to figure it out.

Accedi per commentare.

Risposta accettata

Michael
Michael il 16 Lug 2021
I got a response back from Mathworks Support about this. In short, as suspected, there is an issue with file permissions in Finder that doesn't allow the log file from being generated. As a work around, you can use diary.m in the application to write a file to a known and accessible file. I put this diary.m call in my applications startup function. Below is the response from Mathworks (thanks to Cam at Mathworks Support)
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------
I have found that this issue has to do with how the Finder application starts programs when you double click on them.
When using MATLAB Compiler, if the option is specified to create a log file then the log file will be created in the directory that the compiled application is started from. When we used the generated run script to start the program, this was the directory that the program was in.
When an application is started via Finder, this is not the case. From the limited information that I can find about how Finder works, the application is most likely started from the root directory of the file system: '/'. It is likely that the application does not have access to write in this location, so the log file is not created.
Unfortunately, the '-logfile' flag for the 'mcc' command does not allow us to specify the directory that the file should be placed in, only the name of the file. However, we can workaround this by using the 'diary' function.
The 'diary' function logs any output that would be shown in the Command Window to a file, similarly to how the '-logfile' option works with the 'mcc' command. The difference is that the 'diary' function allows us to specify the location of the file that is created.
To use this, you could simply add the command "diary('/Path/to/destination/log.txt')" to the startup function of your application. The default behavior of the 'diary' function is to append to the file if it already exists, so each time you run the application the log file would become larger.
If you would like a new file to be created for each run of the program, you could use something like the following:
dateString = datestr(clock);
logName = ['/Users/<username>/Desktop/log_' dateString '.txt'];
diary(logName);
By using this method, a new log file will be created for each run of the program, since the name of the file includes the current date and time.
You can find the documentation for the 'diary' function here:
I am going to go ahead and close this case for now, but if you have any additional questions related to this topic please respond to this email and I will be happy to re-open the case to assist you further.

Più risposte (0)

Categorie

Scopri di più su MATLAB Compiler in Help Center e File Exchange

Prodotti


Release

R2020b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by