Got Questions? Get Answers.
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Set path won't save

Subject: Set path won't save

From: Chris

Date: 30 Jun, 2010 12:10:21

Message: 1 of 23

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

Subject: Set path won't save

From: Wayne King

Date: 30 Jun, 2010 12:34:05

Message: 2 of 23

"Chris " <chris.veinot@hotmail.com> wrote in message <i0fc7d$k8e$1@fred.mathworks.com>...
> 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

Do you have write access to your MATLAB startup directory? What platform are you running MATLAB on?

Wayne

Subject: Set path won't save

From: Jan Simon

Date: 30 Jun, 2010 12:36:04

Message: 3 of 23

Dear Chris,

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

Subject: Set path won't save

From: Chris

Date: 30 Jun, 2010 12:48:04

Message: 4 of 23

"Jan Simon" <matlab.THIS_YEAR@nMINUSsimon.de> wrote in message <i0fdnk$rpq$1@fred.mathworks.com>...
> Dear Chris,
>
> > 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 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

Subject: Set path won't save

From: Chris

Date: 30 Jun, 2010 12:50:23

Message: 5 of 23

"Jan Simon" <matlab.THIS_YEAR@nMINUSsimon.de> wrote in message <i0fdnk$rpq$1@fred.mathworks.com>...
> Dear Chris,
>
> > 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 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

Subject: Set path won't save

From: Vivian

Date: 7 Jul, 2010 02:54:05

Message: 6 of 23

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

Subject: Set path won't save

From: kk KKsingh

Date: 7 Jul, 2010 04:08:04

Message: 7 of 23

"Vivian " <vivian.cheung@csiro.au> wrote in message <i10q8d$4hd$1@fred.mathworks.com>...
> 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

Subject: Set path won't save

From: Jan Simon

Date: 7 Jul, 2010 10:54:04

Message: 8 of 23

Dear 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

Subject: Set path won't save

From: Vivian

Date: 8 Jul, 2010 01:27:03

Message: 9 of 23

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.

Subject: Set path won't save

From: Image Analyst

Date: 8 Jul, 2010 02:06:04

Message: 10 of 23

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().

Subject: Set path won't save

From: Jan Simon

Date: 8 Jul, 2010 07:22:04

Message: 11 of 23

Dear Vivian,

> 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

Subject: Set path won't save

From: Marco Rotonda

Date: 8 Jul, 2010 10:01:03

Message: 12 of 23

I've the same problem as Vivian.
The funny thing is that if I add only a folder without the subfolders... it woks!

Subject: Set path won't save

From: Jan Simon

Date: 8 Jul, 2010 10:50:06

Message: 13 of 23

Dear Marco,

> 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

Subject: Set path won't save

From: per isakson

Date: 11 Jul, 2010 01:30:22

Message: 14 of 23

"Jan Simon" <matlab.THIS_YEAR@nMINUSsimon.de> wrote in message <i14agu$s76$1@fred.mathworks.com>...
> Dear Marco,
>
> > 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

I have experienced the very same problem that Vivian describes.

Last winter I got a new PC, which included
1. Update to Windows 7 (64bit) from Windows XP
2. Update to Matlab R2009b (64bit) from R2008b
3. Increased security, which mean I have less control over my PC. Profiles are managed remotely - I don't know the details and things happens automagically.

I was not comfortable with Windows 7 and the new Ms Office. Matlab was a minor nuisance. Anyhow, I could not save my Matlab path. I jumped into the conclusion that something had gone wrong with the installation of Matlab. The permissions were too restricted. After all, why should I change files under the Matlab root?

>> which pathdef
C:\Program Files\MATLAB\R2009b\toolbox\local\pathdef.m

The Start in: folder of the Windows shortcut was empty. (I did not check USERPATH.)

Ok, I decided that this was the time to make a system to help me easily switch between different search paths.
1. I created a new folder ...\Configuration
2. Added "...\Configuration" to the Start in: folder of the the Windows shortcut.
3. Put a copy of PATHDEF in the folder named "...\Configuration"
4. Did something "clever" in STARTUP
5. I never made the switching part work properly

This worked until I updated to R2010a. R2010a was not happy with ...\Configuration\pathdef.m because certain folders of the new Matlab installation was removed from the path by the old pathdef. Now I have removed ...\Configuration and cleared the Start in: field. Saving the path to C:\Program Files\MATLAB\R2010a\toolbox\local\pathdef.m works fine again.

((
1. USERPATH returned empty
2. Thus, I run >> userpath('reset')
3. Now userpath returns C:\Users\poi\Documents\MATLAB; (BTW:
"Documents" is shown as "My Documents" by Windows Explorer.)
4. However, that folder is empty and I don't think I ever used it.

Sometimes, both now and with my old PC, Matlab starts in "C:\Windows\system32" and I cannot understand why.
))

QUESTIONS:
1. Where is "the best" place to keep pathdef.m? Should I leave the Start in: field empty? What about USERPATH?
2. I did not find a "Switch search path tool" in the FEX. (However, File ID: #23218, Project Manager, by Sung Soo Kim, does it and more.) Which are the most important things I should think about if I try to make a "Switch search path tool". Updating Matlab realese is certainly one.

IMO: Matlab sometimes behaves mysteriously and in many cases the documentation could be more helpful, e.g. the documentation of USERPATH.

/ per

Subject: Set path won't save

From: Gregory Teplow

Date: 6 Aug, 2010 21:43:04

Message: 15 of 23

I think that I had the same problem in Windows 7.
SOLUTION!: in Windows 7, change the "permissions" for the user account that you are using so that you can write to that folder. (I editted the permission for C:\Program Files\MATLAB) I changed mine to "full control" so that I could do whatever I wanted, but less permission might work too.

Hope that helps!

Subject: Set path won't save

From: Daniel

Date: 19 Aug, 2010 15:43:09

Message: 16 of 23

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

"Chris " <chris.veinot@hotmail.com> wrote in message <i0fc7d$k8e$1@fred.mathworks.com>...
> 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

Subject: Set path won't save

From: Ronen

Date: 14 Sep, 2010 07:30:13

Message: 17 of 23

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.

"Daniel " <dlee@hpl.umces.edu> wrote in message <i4jjed$alc$1@fred.mathworks.com>...
> 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
>
> "Chris " <chris.veinot@hotmail.com> wrote in message <i0fc7d$k8e$1@fred.mathworks.com>...
> > 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

Subject: Set path won't save

From: Paolo Manganelli

Date: 11 Jan, 2011 10:39:10

Message: 18 of 23

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.

Subject: Set path won't save

From: James

Date: 20 Jun, 2011 15:43:04

Message: 19 of 23

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.

Subject: Set path won't save

From: denny

Date: 4 Jan, 2012 05:10:10

Message: 20 of 23

It worked for me. Thank you so much.
"Ronen " <ronen.lif@gmail.com> wrote in message <i6n8a5$ikv$1@fred.mathworks.com>...
> 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.
>
> "Daniel " <dlee@hpl.umces.edu> wrote in message <i4jjed$alc$1@fred.mathworks.com>...
> > 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
> >
> > "Chris " <chris.veinot@hotmail.com> wrote in message <i0fc7d$k8e$1@fred.mathworks.com>...
> > > 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

Subject: Set path won't save

From: Eric Lin

Date: 27 Jan, 2014 14:26:08

Message: 21 of 23

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.

Subject: Set path won't save

From: Natalie

Date: 2 Apr, 2014 01:18:11

Message: 22 of 23

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?

Subject: Set path won't save

From: TideMan

Date: 2 Apr, 2014 02:40:42

Message: 23 of 23

On Wednesday, April 2, 2014 2:18:11 PM UTC+13, Natalie wrote:
> 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

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us