Why do I get a warning or error regarding "Executing startup failed in matlabrc" and "MATLAB:mp​ath:PathAl​terationNo​tSupported​" when I start my standalone application?

24 views (last 30 days)
When I try to run my standalone executable generated by MATLAB Compiler, or standalone package generated by MATLAB Compiler SDK, I may get warnings or errors that mention "startup" and "MATLAB:mpath:PathAlterationNotSupported".
The warning could be:
Warning: Executing startup failed in matlabrc.
This indicates a potentially serious problem in your MATLAB setup, which
should be resolved as soon as possible. Error detected was:
MATLAB:mpath:PathAlterationNotSupported
Modifying the search path is not supported by MATLAB Compiler. Remove functions
that modify the search path from your MATLAB code. To make files visible to your
deployed application, add the parent folder to your MATLAB session.
The error could be:
Error using matlabpath
Modifying the search path is not supported by MATLAB Compiler. Remove functions
that modify the search path from your MATLAB code. To make files visible to your
deployed application, add the parent folder to your MATLAB session.
Error in path (line 109)
Error in addpath (line 86)
Error in startup (line 2)
MATLAB:mpath:PathAlterationNotSupported

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 19 Jul 2023
This warning or error occurs when a "startup.m" file containing "addpath" commands is present on your MATLAB path when the application is compiled. The "addpath" command is not supported by MATLAB Compiler.
To resolve this, locate all startup.m files using:
>> which startup -all
Then, modify the startup.m script(s) so that the content is enclosed by the "isdeployed" flag:
if ~isdeployed
  % startup script
end
In this way, the startup script code will not be run in the deployed standalone application. For more information, see:
If modifying the startup script(s) is not possible, you could temporarily remove the path containing the scripts while the application is packaged.
This could be achieved using a scripted workflow as follows:
rmpath('path/to/startupFile') % remove folder containing startup.m file from MATLAB path for current session
mcc .... % MCC command to package application - can be copied from Packaging Log
addpath('path/to/startupFile') % optional - restore folder containing startup.m file to MATLAB path for current session

More Answers (0)

Categories

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

Tags

No tags entered yet.

Products


Release

R2022b

Community Treasure Hunt

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

Start Hunting!