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

126 visualizaciones (últimos 30 días)
Leon
Leon el 4 de Abr. de 2019
Comentada: A Jorge el 26 de Sept. de 2020
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.

Respuestas (1)

Walter Roberson
Walter Roberson el 18 de Jun. de 2019
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 comentario
A Jorge
A Jorge el 26 de Sept. de 2020
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.

Iniciar sesión para comentar.

Categorías

Más información sobre Startup and Shutdown en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by