Path Unsuccessfully Set at Startup

When there is a problem with the search path, you cannot use MATLAB® successfully.

Search path problems occur when:

  • You save the search path on a Windows® platform, and then try to use the same pathdef.m file on a Linux® platform.

  • The pathdef.m file becomes corrupt, invalid, renamed, or deleted.

  • MATLAB cannot locate the pathdef.m file.

When MATLAB starts, if there is a problem with the search path, a message such as the following appears:

Warning: MATLAB did not appear to successfully set the search 
path...

For problems with the search path, try these recovery steps. Proceed from one step to the next only as necessary.

  1. Ensure MATLAB is using the pathdef.m file you expect:

    1. Run

      which pathdef
    2. If you want MATLAB to use the pathdef.m file at another location, make corrections. For example, delete the incorrect pathdef.m file and ensure the correct pathdef.m file is in a location that MATLAB can access.

  2. Look for and correct problems with the pathdef.m and startup.m files:

    1. Open pathdef.m and startup.m in a text editor. Depending on the problem, you might not be able to open the pathdef.m file.

    2. Look for obvious problems, such as invalid characters or path names.

    3. Make corrections and save the files.

    4. Restart MATLAB to ensure that the problem does not recur.

  3. Try to correct the problem using the Set Path dialog box:

    1. Restore the default search path and save it. See Change Folders on the Search Path. Depending on the problem, you might not be able to open the dialog box.

    2. Restart MATLAB to ensure that the problem does not recur.

  4. Restore the default search path using functions:

    1. Run restoredefaultpath, which sets the search path to the default and stores it in matlabroot/toolbox/local.

    2. If restoredefaultpath seems to correct the problem, run savepath.

    3. Restart MATLAB to ensure that the problem does not recur.

    Depending on the problem, a message such as the following could appear:

    The path may be bad. Please save your work (if desired), and quit.
  5. Correct the search path problems encountered during startup:

    1. Run

      restoredefaultpath; matlabrc

      Wait a few minutes until it completes.

    2. If there is a pathdef.m file in the startup folder, it caused the problem. Either remove the bad pathdef.m file or replace it with a good pathdef.m file. For example, run:

      savepath('path_to_your_startup_folder/pathdef.m')

      See MATLAB Startup Folder.

    3. Restart MATLAB to ensure that the problem does not recur.

After correcting problems with the search path, make any changes to run your files. For example, add the userpath folder or other folders to the search path.

Was this topic helpful?