Main Content

Resolve Issue: MATLAB Did Not Appear to Successfully Set the Search Path

Issue

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

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

If 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.

Possible Solutions

For problems with the search path, try these recovery steps. Proceed from one possible solution to the next only as necessary. After correcting problems with the search path, make any changes to run your files. For example, us userpath to add the userpath folder to the search path or use addpath to add other folders to the search path.

Confirm Correct pathdef.m File Is Being Used

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

which pathdef

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.

Restart MATLAB to ensure that the problem does not recur.

Fix Problems In pathdef.m And startup.m Files

Look for and correct problems with the pathdef.m and startup.m files by following these steps:

  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.

Restore the Default Path

Run restoredefaultpath, which sets the search path to the default and stores it in matlabroot/toolbox/local. If restoredefaultpath seems to correct the problem, run savepath.

Restart MATLAB to ensure that the problem does not recur.

Depending on the problem, the following message could appear during this workflow:

The path may be bad. Please save your work (if desired), and quit.

Restore Default Path Using the Set Path Dialog Box

Try to correct the problem using the Set Path dialog box. On the Home tab, in the Environment section, click Set Path. The Set Path dialog box appears. Alternatively, you can access this dialog box using the pathtool function.

Set Path dialog box showing several MATLAB search paths

Click Default to restore the default search path and then click Save to save it. See Change Folders on Search Path for additional information on using the Set Path Dialog box. Depending on the problem, you might not be able to open the dialog box.

Restart MATLAB to ensure that the problem does not recur.

Correct Search Path Problems Encountered During Startup

Run the following command:

restoredefaultpath; matlabrc

Wait a few minutes until it completes.

Once the command completes, if there is a pathdef.m file in the startup folder, then it caused the problem. Either remove the problematic pathdef.m file or replace it with a functional pathdef.m file. For example, run:

savepath('path_to_your_startup_folder/pathdef.m')

See MATLAB Startup Folder for additional information..

Restart MATLAB to ensure that the problem does not recur.

See Also

| |

Related Topics