Why does MATLAB Compiler issue a warning regarding "startup.m" adding paths?

57 views (last 30 days)
Why does creating a standalone application in MATLAB R2017a or later generate the folllowing warning regarding "startup.m" adding paths?
ERROR: Warning: Your deployed application may error out because file or folder paths
not present in the deployed environment may be included in your MATLAB startup
file. Use the MATLAB function "isdeployed" in your MATLAB startup file to
determine the appropriate execution environment when including file and folder
paths, and recompile your application.

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 22 Feb 2024
Edited: MathWorks Support Team on 22 Feb 2024
The warning message was introduced in R2017a and is intended to let the users know that having a user-defined startup script for MATLAB ("startup.m" ) may cause errors in the deployment environment, since "startup.m" files will be compiled into the application. It also recommends using the "isdeployed" function to determine the current execution environment.
Note that getting this warning does not necessarily mean that the "startup.m" file(s) have any code that is changing or adding paths. The warning is emitted if any "startup.m" is present on the MATLAB path, or in any path that contains files that the packaged application depends on.
Make sure to inspect the "startup.m" files present in your MATLAB installation:
>> which startup.m -all
Determine whether the content present in the "startup.m" files is relevant to your compiled application. The recommended structure for startup.m files is the following:
% startup.m file
if ~isdeployed
% statements under this block will execute at startup
% when you run MATLAB on your desktop
else
% statements under this block will execute at startup
% when MATLAB compiled application is run on a deployed machine
end
% add statements outside the if-else block if you would like to execute them on both your desktop and deployed machines
One example of useful startup code that could be added to a deployed application is to turn off warnings for all deployed applications:
if isdeployed
warning off
end
  1 Comment
Bruno Luong
Bruno Luong on 6 Jul 2022
"When you add files using the -a flag ...As a result, the dependency analyzer is able to find 'startup.m' file and hence gives the warning message."
Sorry it doesn' make much sense to me. Why it is matter the dependency analyzer find startup and user added file that migh have nothing to do with startup?
This warning is too sensitive and unjustified, and thus anoying

Sign in to comment.

More Answers (1)

Bruno Luong
Bruno Luong on 6 Jul 2022
Edited: Bruno Luong on 6 Jul 2022
Turn off the warning
warning('off','Compiler:compiler:COM_WARN_STARTUP_FILE_INCLUDED')
You might put it in your startup.m so that this anoying warning does appear anymore.
Don't delete you startup.m it's there for a reason.
It's just me but I think the startup should never be included in the compilation, at least we must have a switch option NOT to include it during the compilation.

Categories

Find more on Startup and Shutdown in Help Center and File Exchange

Products


Release

R2019b

Community Treasure Hunt

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

Start Hunting!