Setpath error: the path file pathdef.m might be read only

104 次查看(过去 30 天)
I need some external functions to run my program. They are saved in a different folder. The problem I'm having is that I can not save my setpath settings. Below is the error message:
Matlab can not save changes to the path
The path file, pathdef.m, might be read only or might be in a folder for which you do not have write access.

回答(1 个)

Walter Roberson
Walter Roberson 2019-6-18
MATLAB generally creates a writeable pathdef.m when it is installed, but not always. Sometimes pathdef.m ends up in a directory that you do not have write access to. This tends to happen a bit more often with Linux because of the way that installation is done with sudo .
in MS Windows, the easiest workaround is often to Run As Administrator once, and savepath and the permissions will typically end up correct after that (but not always.)
You should use
which -all pathdef.m
to find out where pathdef.m is. Then examine the ownership for it, and examine the security permissions for the directory that it lives in .
If it turns out that pathdef.m lives in a directory that you should not have write access to, then you should use savepath and name a location that you do have write access to.
At run time, pathdef is searched for along the path:
"savepath saves the current MATLAB® search path to an existing pathdef.m file in the current folder. If there is no pathdef.m file in the current folder, then savepath saves the search path to the first pathdef.m file on the current path. If there is no such file on the current path, then savepath saves the search path to the pathdef.m file that MATLAB located at startup."
  1 个评论
A Jorge
A Jorge 2020-9-26
For mac IOS users (and maybe linux), simply go to the Pathdef.m file out of the Matlab Application folder ("go to your applications folder, right click on Matlab and Show Package Contents" on a Mac, under Matlab_R20xxb.app\toolbox\local). Navigate to this folder address, right click pathdef.m file, click get info, unlock the lock with your password at the bottom (you need admin privileges here I believe) and change the Privilege column at the very bottom from Read to Read & Write. You need to restart matlab for the change to take effect.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Startup and Shutdown 的更多信息

标签

产品


版本

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by