Why do I receive the warning message "Warning: Name is nonexistent or not a directory: .... " when I start MATLAB?

54 views (last 30 days)
I receive warning messages similar to the ones below whenever MATLAB starts up:
Warning: Name is nonexistent or not a directory: D:\work\myFolder1. Warning: Name is nonexistent or not a directory: D:\work\myFolder2. Warning: Name is nonexistent or not a directory: D:\work\myFolder3.
Note: The warning message could be about different folders but essentially begins with "Warning: Name is nonexistent or not a directory".

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 3 Sep 2024
Edited: MathWorks Support Team on 3 Sep 2024
These warnings could be due to one of the following possible scenarios:
1. The indicated directories are in the 'pathdef.m' file used by MATLAB, but the directories do not exist in the file system.
2. The directories are added to the MATLAB path using a custom 'startup.m' file and the directories do not exist in the file system.
To troubleshoot this issue, please type the following at the MATLAB prompt:
which -all pathdef.m
The topmost line of the output represents the 'pathdef.m' file currently used by MATLAB.
If the topmost line in the output is NOT $matlabroot\toolbox\local\pathdef.m (where $matlabroot is the output of typing 'matlabroot' at the MATLAB prompt), it means that the 'pathdef.m' in use by MATLAB was not updated by the installer, and the directory structure of MATLAB-code was changed since the previous version of MATLAB.
(Note: The installer only updates $matlabroot\toolbox\local\pathdef.m during a MATLAB installation.)
If you did not create the 'pathdef.m' file that appears as the topmost output, are not concerned about which 'pathdef.m' file MATLAB uses, or wish to use the latest 'pathdef.m' file updated by the installer, please rename or delete all the 'pathdef.m' files from the output above except for $matlabroot\toolbox\local\pathdef.m.
However, if you wish to continue using the existing 'pathdef.m' file, follow these steps:
Update the above 'pathdef.m' file with the latest path information by typing the following at the MATLAB prompt. (Please note that this would delete all the previous path information and replace it with the factory settings. Hence, you might want to back up the old pathdef.m file so that you can use other path information from it at a later period.)
>> restoredefaultpath; savepath;
Note: The warning may be a symptom of a bigger issue. If the pathdef.m file created by the installer isn’t being used, not only will removed directories cause the warnings, but new directories in the new release will not be added to the MATLAB path. This could result in a much bigger issue.
However, if none of the above steps resolve the issue, then it's possible that there exists a 'startup.m' file which is adding these non-existent directories to the path. You can edit the 'startup.m' file by typing the following at the MATLAB prompt and then delete the lines that are adding the directories that appear in the warning message:
>> edit startup.m
If you are explicitly adding directories to your path in startup.m, make sure you are doing so recursively by using the GENPATH command as in:
addpath(genpath(<myDirectory>));
.
Note: If you are receiving warnings regarding an editor path in R2020a or R2020b, please see the following Answer for workarounds:

More Answers (0)

Categories

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

Tags

No tags entered yet.

Products

Community Treasure Hunt

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

Start Hunting!