Discussion:
Set path won't save
(too old to reply)
Chris
2010-06-30 12:10:21 UTC
Permalink
When I'm setting a path in MatLab and try to save my changes so I don't have to set it everytime I get the error message:
|
MATLAB cannot save changes to the path.

The path file, pathdef.m, might be read-only or might be in a directory for which you do not have write access.

You can save pathdef.m to a different location. In order for MATLAB to use that pathdef.m in future sessions, you need to save it in your MATLAB startup directory (the direcotry from which you start MATLAB).

Would you like to save pathdef.m to another location?
|

So I click yes and save in in the start up directory and it just sends me the same message again.

Thanks for the help
Wayne King
2010-06-30 12:34:05 UTC
Permalink
Post by Chris
|
MATLAB cannot save changes to the path.
The path file, pathdef.m, might be read-only or might be in a directory for which you do not have write access.
You can save pathdef.m to a different location. In order for MATLAB to use that pathdef.m in future sessions, you need to save it in your MATLAB startup directory (the direcotry from which you start MATLAB).
Would you like to save pathdef.m to another location?
|
So I click yes and save in in the start up directory and it just sends me the same message again.
Thanks for the help
Do you have write access to your MATLAB startup directory? What platform are you running MATLAB on?

Wayne
Jan Simon
2010-06-30 12:36:04 UTC
Permalink
Dear Chris,
Post by Chris
MATLAB cannot save changes to the path.
The path file, pathdef.m, might be read-only or might be in a directory for which you do not have write access.
You forgot to ask a question. I assume, that you want to get write-privilegs for the folder PATHDEF.M is saved in. If you work on a multi-user system, it is better to use a PATHDEF.M file for each user, therfore Matlab suggests to copy it to a user-related folder.
If you mention your Matlab version, OS and your initial workpath, we could give some more advices.

Kind regards, Jan
Chris
2010-06-30 12:48:04 UTC
Permalink
Post by Jan Simon
Dear Chris,
Post by Chris
MATLAB cannot save changes to the path.
The path file, pathdef.m, might be read-only or might be in a directory for which you do not have write access.
You forgot to ask a question. I assume, that you want to get write-privilegs for the folder PATHDEF.M is saved in. If you work on a multi-user system, it is better to use a PATHDEF.M file for each user, therfore Matlab suggests to copy it to a user-related folder.
If you mention your Matlab version, OS and your initial workpath, we could give some more advices.
Kind regards, Jan
Im using windows 7 and have MATLAB R2009b
Chris
2010-06-30 12:50:23 UTC
Permalink
Post by Jan Simon
Dear Chris,
Post by Chris
MATLAB cannot save changes to the path.
The path file, pathdef.m, might be read-only or might be in a directory for which you do not have write access.
You forgot to ask a question. I assume, that you want to get write-privilegs for the folder PATHDEF.M is saved in. If you work on a multi-user system, it is better to use a PATHDEF.M file for each user, therfore Matlab suggests to copy it to a user-related folder.
If you mention your Matlab version, OS and your initial workpath, we could give some more advices.
Kind regards, Jan
I just tried what you suggested by saving it to a user-related folder and it worked! Thanks for the help
Vivian
2010-07-07 02:54:05 UTC
Permalink
Hi,
I have the same problem and I would like to save the new paths in the original MATLAB pathdef.m. I am using window 7, MATLAB 2010a, and I have write access to the MATLAB directory where it is installed. I could open the pathdef.m file, edit it and save it using the editor, but I couldn't save the new paths using File->Set Path ->Save.
Any advices?

Thanks,
Vivian
kk KKsingh
2010-07-07 04:08:04 UTC
Permalink
Post by Vivian
Hi,
I have the same problem and I would like to save the new paths in the original MATLAB pathdef.m. I am using window 7, MATLAB 2010a, and I have write access to the MATLAB directory where it is installed. I could open the pathdef.m file, edit it and save it using the editor, but I couldn't save the new paths using File->Set Path ->Save.
Any advices?
Thanks,
Vivian
1. It should work through File > setpath>add all subfolders > save

2. Other way save all the files in same folder, it will work

Thanks

Kumar
Jan Simon
2010-07-07 10:54:04 UTC
Permalink
Dear Vivian,
Post by Vivian
I could open the pathdef.m file, edit it and save it using the editor, but I couldn't save the new paths using File->Set Path ->Save.
If you can modify "pathdef.m" manually, it is really strange, that the Save button cannot save. Please describe exactly, what "I couldn't save" means - error message, file not touched??

Jan
Vivian
2010-07-08 01:27:03 UTC
Permalink
The error message is:

MATLAB cannot save changes to the path.

The path file, pathdef.m, might be read-only or might be in a directory for which you do not have write access.

You can save pathdef.m to a different location. In order for MATLAB to use that pathdef.m in future sessions, you need to save it in your MATLAB startup directory (the direcotry from which you start MATLAB).

Would you like to save pathdef.m to another location?

When I clicked "yes" and tried to save it to my user MATLAB directory, this error message popped up again, without creating a pathdef.m file under my user MATLAB directory. I have also tried to copy and paste the pathdef.m from MATLAB root to my user directory, but when I clicked save after adding path with subfolders, it gave me the same error message again.
Image Analyst
2010-07-08 02:06:04 UTC
Permalink
Would you want to just save the path as the default for all sessions? Why don't you just modify your startup.m file with lines like these:

if(~isdeployed)
addpath(genpath('C:\Program Files\MATLAB\Work'));
cd 'C:\Program Files\MATLAB\work'
savepath;
end

Note the use of savepath().
Jan Simon
2010-07-08 07:22:04 UTC
Permalink
Dear Vivian,
Post by Chris
MATLAB cannot save changes to the path.
The path file, pathdef.m, might be read-only or might be in a directory for which you do not have write access.
Again: Please check another time if this is true.
which('pathdef.m', '-all') % Multiple files?
oneFile = which('pathdef.m');
fileattrib(oneFile)
fileattrib(fileparts(oneFile))
Is UserWrite enabled whereever needed?
I cannot find the function which is responsible for the error message. Perhaps you have shadowed the function, which checks writabilty of the PATHDEF.M file?!

Kind regards, Jan
Marco Rotonda
2010-07-08 10:01:03 UTC
Permalink
I've the same problem as Vivian.
The funny thing is that if I add only a folder without the subfolders... it woks!
Jan Simon
2010-07-08 10:50:06 UTC
Permalink
Dear Marco,
Post by Marco Rotonda
I've the same problem as Vivian.
The funny thing is that if I add only a folder without the subfolders... it woks!
Vivians problem seems to be, that she cannot save PATHDEF.M automatically, but manually it works.
Where is the relation to "add a folder without the subfolders"?

Vivians problem sounds very strange and something mysterious seems to happen. My experiences tell me, that in 99.9% of the casesl mysteriums become wrong input or wrong expectations, after the problem has been defined and explained exactly. The tiny rest is caused by damaged RAM or CPUs.

Kind regards, Jan
per isakson
2010-07-11 01:30:22 UTC
Permalink
This post might be inappropriate. Click to display it.
Gregory Teplow
2010-08-06 21:43:04 UTC
Permalink
This post might be inappropriate. Click to display it.
Daniel
2010-08-19 15:43:09 UTC
Permalink
It seems like person who asked this question already fixed this problem. However, I would like to explain how I solved this problem.

My computer: windows 7, 64-bit, student version MATLAB2010

First, I should give a permission to me to access to toolbox folder. I just bought the new computer and didn't use window7 before. It is weird why the owner (me) doesn't have a full access to any folders. Anyway, I had given the full access to MATLAB related folders (toolbox, MATLAB, etc.) but still I couldn't have the access and couldn't run a set path command. I cannot remember which folder it was (I think....folder 'Toolbox'), but suddenly right after I changed the permission in the window property and click OK, there was new pop-up saying something like "changing all security setting for all sub-folders". Then, it took about 2 minutes to change all security setting for all Toolbox's sub-folders.

So, the bottom line is that you should change the access setting until you fully change all security setting for all MATLAB or Toolbox sub-folders.

D
Post by Chris
|
MATLAB cannot save changes to the path.
The path file, pathdef.m, might be read-only or might be in a directory for which you do not have write access.
You can save pathdef.m to a different location. In order for MATLAB to use that pathdef.m in future sessions, you need to save it in your MATLAB startup directory (the direcotry from which you start MATLAB).
Would you like to save pathdef.m to another location?
|
So I click yes and save in in the start up directory and it just sends me the same message again.
Thanks for the help
Ronen
2010-09-14 07:30:13 UTC
Permalink
Hi all,

My small addition:

...just right-click the MATLAB icon and choose "Run as administrator". this particular MATLAB session will allow pathdef to be saved.

NOTE: this procedure is required even if you belong to the Administrators group of your PC/Laptop.

I had similar problems in other software products (e.g. Labview) and the same solution works for all. This is probably an extra-security feature of Windows 7, which is very good in general.

Cheers,
- Ronen.
Post by Daniel
It seems like person who asked this question already fixed this problem. However, I would like to explain how I solved this problem.
My computer: windows 7, 64-bit, student version MATLAB2010
First, I should give a permission to me to access to toolbox folder. I just bought the new computer and didn't use window7 before. It is weird why the owner (me) doesn't have a full access to any folders. Anyway, I had given the full access to MATLAB related folders (toolbox, MATLAB, etc.) but still I couldn't have the access and couldn't run a set path command. I cannot remember which folder it was (I think....folder 'Toolbox'), but suddenly right after I changed the permission in the window property and click OK, there was new pop-up saying something like "changing all security setting for all sub-folders". Then, it took about 2 minutes to change all security setting for all Toolbox's sub-folders.
So, the bottom line is that you should change the access setting until you fully change all security setting for all MATLAB or Toolbox sub-folders.
D
Post by Chris
|
MATLAB cannot save changes to the path.
The path file, pathdef.m, might be read-only or might be in a directory for which you do not have write access.
You can save pathdef.m to a different location. In order for MATLAB to use that pathdef.m in future sessions, you need to save it in your MATLAB startup directory (the direcotry from which you start MATLAB).
Would you like to save pathdef.m to another location?
|
So I click yes and save in in the start up directory and it just sends me the same message again.
Thanks for the help
Paolo Manganelli
2011-01-11 10:39:10 UTC
Permalink
Had exactly the same problem (could not save path) on Win7,x64,R2010b

- Running as Admin did not work for me
- I had full privileges on the whole Matlab installation folder (not under Program files) and subfolders, yet, when trying to add the "Work" folder with all its subfolders to the path, it would not let me, claiming lack of permission to write.

WHAT WORKED:
Using Matlabs "set path" interface (File/Set Path)
* I first added the only "Work" folder to the path WITHOUT SUBFOLDERS.
* The saved the new path.
* Then added all the subfolders of the "Work" folder.
* Then saved again the path.
James
2011-06-20 15:43:04 UTC
Permalink
What worked for me:

I checked the security tab for pathdef.m and everything looked good (I'm admin my account had full access). This puzzled me for a while. Then I checked top level permissions on the C: -> Program Files -> MALTAB and the Read Only box was checked. Unchecked it and applied those permissions and it all worked. Check if your read only box is checked, sometimes the security tab can be misleading.
denny
2012-01-04 05:10:10 UTC
Permalink
It worked for me. Thank you so much.
Post by Ronen
Hi all,
...just right-click the MATLAB icon and choose "Run as administrator". this particular MATLAB session will allow pathdef to be saved.
NOTE: this procedure is required even if you belong to the Administrators group of your PC/Laptop.
I had similar problems in other software products (e.g. Labview) and the same solution works for all. This is probably an extra-security feature of Windows 7, which is very good in general.
Cheers,
- Ronen.
Post by Daniel
It seems like person who asked this question already fixed this problem. However, I would like to explain how I solved this problem.
My computer: windows 7, 64-bit, student version MATLAB2010
First, I should give a permission to me to access to toolbox folder. I just bought the new computer and didn't use window7 before. It is weird why the owner (me) doesn't have a full access to any folders. Anyway, I had given the full access to MATLAB related folders (toolbox, MATLAB, etc.) but still I couldn't have the access and couldn't run a set path command. I cannot remember which folder it was (I think....folder 'Toolbox'), but suddenly right after I changed the permission in the window property and click OK, there was new pop-up saying something like "changing all security setting for all sub-folders". Then, it took about 2 minutes to change all security setting for all Toolbox's sub-folders.
So, the bottom line is that you should change the access setting until you fully change all security setting for all MATLAB or Toolbox sub-folders.
D
Post by Chris
|
MATLAB cannot save changes to the path.
The path file, pathdef.m, might be read-only or might be in a directory for which you do not have write access.
You can save pathdef.m to a different location. In order for MATLAB to use that pathdef.m in future sessions, you need to save it in your MATLAB startup directory (the direcotry from which you start MATLAB).
Would you like to save pathdef.m to another location?
|
So I click yes and save in in the start up directory and it just sends me the same message again.
Thanks for the help
Eric Lin
2014-01-27 14:26:08 UTC
Permalink
I once had this problem. I was using 2010a and later I installed 2013a without uninstall 2010a. After that I mainly coding on 2013a. And I found that when I reopen 2013a, the previous changes made to path is gone. But there was no error using addpath('') or path(path,'').
I googled for this kind of problems and I think I might have dual pathdef.m.
It turns out that addpath in 2013a modify path in C:\Users\____\Documents\MATLAB\pathdef.m . And path initialization of 2013a utilize C:\Program Files\MATLAB\R2013a\toolbox\local\pathdef.m
Problem solved by manually copy pathdef from Documents to Program files.
Natalie
2014-04-02 01:18:11 UTC
Permalink
I have the same problem. It doesn't matter WHERE I try to save the new pathfile to, it complains that it cannot be saved. Is there a fix for this?
TideMan
2014-04-02 02:40:42 UTC
Permalink
Post by Natalie
I have the same problem. It doesn't matter WHERE I try to save the new pathfile to, it complains that it cannot be saved. Is there a fix for this?
What I found with 2013a is that the default directory for pathdef is:
c:\Users\me\Documents\MATLAB
but there is no such directory.
The directory is actually:
c:\Users\me\My Documents\MATLAB
I've worked around this by putting this line:
addpath(pathdef)
in startup.m
Randy Sage
2016-12-06 02:00:03 UTC
Permalink
On a Linux MATLAB R2013a environment, I encountered the same initial error and I need to be able to have different paths for different users.

The solution for me seems to be to run restoredefaultpath and then echo the path to determine the user's default path (~/Documents/MATLAB on this version) and then copy pathdef.m from the `which pathdef` location into this user-specific folder.

As this folder is at the top of the default path list, this should be stable and reliable so long as nobody ever adds a different pathdef in a higher priority future, customized path. (E.g., `addpath('/path/to/dir/containing/read/only/pathdef/'`
Continue reading on narkive:
Loading...