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

96 ビュー (過去 30 日間)
Leon
Leon 2019 年 4 月 4 日
コメント済み: A Jorge 2020 年 9 月 26 日
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 件のコメント
Sergio Yanez-Pagans
Sergio Yanez-Pagans 2019 年 6 月 18 日
I have the same problem, hopefully someone can answer this question

サインインしてコメントする。

回答 (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 Center および File ExchangeStartup and Shutdown についてさらに検索

タグ

製品


リリース

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by