Why do I get a permission denied error in regards to classpath.txt or pathdef.m when starting MATLAB?

390 views (last 30 days)
MATLAB does not start properly or run after being started. The command window displayed this error:
ERROR: C:\Program Files\MATLAB\R2012b\toolbox\local\classpath.txt: Cannot open file: permission denied.
ERROR: C:\Program Files\MATLAB\R2012b\toolbox\local\pathdef.m: Cannot open file: permission denied.
How can I fix this error?

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 15 Jun 2022
Edited: MathWorks Support Team on 11 Jan 2023 at 11:22
This error indicates that the user account you are executing MATLAB under does not have Read permissions for the classpath.txt or pathdef.m file, which is required to run MATLAB.
To resolve this issue, navigate to the file's location (see path in error message) and add Read permissions for your user. If you are unable to change permissions on your machine, contact your system administrator.
If any files are missing, try a clean re-installation of the software.
  1 Comment
Jan on 7 Jun 2017
Edited: Jan on 8 Jun 2017
A user account without read permissions? Then Matlab should not start at all. Do you mean write permissions?
This is a really bad idea. Under Windows Matlab is installed in the Program Files folder as default. Changing the permissions for the complete installation folder is a severe drawback from the viewpoint of security. Then a virus do not need to elevate its permissions to infect an executable.
In addition users can modify Matlab's toolbox functions by accident afterwards. Concerning problem occurred repeatedly in this forum: a user opens a toolbox file in the editor and hits any key without beeing aware. Then closing the editor asks for saving and "ok" sounds fair.
See my answer for further ideas.

Sign in to comment.

More Answers (6)

Yasin ozkanca
Yasin ozkanca on 27 Apr 2018
Just run Matlab as Administrator and it will solve your problem.

Jan on 7 Jun 2017
Better change the permissions for the pathdef.m and classpath.txt files only, or at least only <matlabroot>\toolbox\local. This has a drawback on a multi-user machine: Then all users can adjust pathdef.m to you needs and the next user might be confused.
Prefer user-defined pathdef.m files inside a folder belonging to the user path. This is save and allows individual changes.
I'm using a different strategy: I've edited the <matlabroot>\toolbox\local\pathdef.m to add the folder "D:\MFiles\Inits". This fiolder contains user defined functions to add the personal set of folders to the path dynamically. This allows multiple users to work on one machine and different projects or versions also without the danger of interferences.
Simon Matte
Simon Matte on 12 Jan 2021
I've had this EXACT problem (except the Start parralel pool stalled 100% of the time). After painstakingly searching for the issue all day, I've narrowed it down to the presence of my pathdef.m file. Removing it fiexed the issue. (It arised initially because I've transfered all my personnal matlab-folder containing my codes and functions from 1 machine to another)
I wish this topic would have come up in my Google searches for "Parralel pool won't start", because I had exhausted every other possible fix suggested at that point.

Sign in to comment.

Judith Martinez
Judith Martinez on 16 May 2021
Edited: Judith Martinez on 16 May 2021

埃博拉酱 on 27 Nov 2021
This is a very ugly design!
All path settings should be user-wide instead of system-wide by default! MATLAB default pathdefs should stay in Installation folder still, but each user should have his own self-added pathdef in the user directory like %APPDATA%\MathWorks\MATLAB\R2021b! Then each user can edit his own pathdef as he like, without any side effect on other users!

Adeel Ashraf
Adeel Ashraf on 7 Jun 2017
very simple just create new folder on desktop etc and copy it path and paste on command window after write cd like this cd 'paste path here' or cd 'C:\Users\Adeel011\Desktop\matlabexample'

Akash kumar
Akash kumar on 15 Mar 2021
Edited: Akash kumar on 15 Mar 2021
Alternative solution:-
Instead of taken the local variable, take global variable and it can solve your problem.
And you can also save the file and parallely take the global variable for denied the permission.


Find more on Startup and Shutdown in Help Center and File Exchange


No tags entered yet.


Community Treasure Hunt

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

Start Hunting!

Translated by