MATLAB: Does creating a standalone application generate a warning regarding “startup.m” adding paths

applicationMATLAB Compilerstandalonestartup.mwarning

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.

Best Answer

The warning message was introduced in R2017a and is intended to let the customers know that having a user-defined startup script for MATLAB ("startup.m" ) may cause errors in the deployment environment. It also recommends using "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.
Workarounds:
1. Inspect the "startup.m" files present in your installation:
>> which startup.m -all
If the content present in the "startup.m" files is irrelevant to your compiled application, you can simply ignore the warning.
To suppress the warning, you would need to either rename or remove the "startup.m" file(s) from the MATLAB path. However, note that this may cause issues with your local MATLAB environment, depending on the purpose of those "startup.m" file(s).
2. When you add files using the -a flag that do not appear on the MATLAB path at the time of compilation, a path entry is added to the application's run-time path so that they appear on the path when the deployed code executes. If you use the -a flag to include a file that is not on the MATLAB path, the folder containing the file is added to the MATLAB dependency analysis path. As a result, the dependency analyzer is able to find 'startup.m' file and hence gives the warning message.
As a workaround, make sure that the files you are adding using -a flag are not in the same folder where 'startup.m' file is present.