Message appearing on start of the Matlab 2019a
10 views (last 30 days)
Show older comments
Following message appears on the start of MATLAB
Cannot create file migratePref.txt!
java.io.IOException: The system cannot find the path specified
at java.io.WinNTFileSystem.createFileExclusively(Native Method)
at java.io.File.createNewFile(File.java:1012)
at com.mathworks.services.Prefs.readMigrateFlag(Prefs.java:2153)
at com.mathworks.services.Prefs.createTwoWayMapPrefsSettings(Prefs.java:373)
at com.mathworks.services.Prefs.<clinit>(Prefs.java:214)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:264)
at com.mathworks.util.PostVMInit$StartupClass.init(PostVMInit.java:156)
at com.mathworks.util.PostVMInit.perform(PostVMInit.java:187)
On trying to start the simulink following message is coming
simulink
Cannot write to preference file "matlab.prf" in "C:\MATLAB_preferences ".
Check file permissions.
Cannot write to preference file "matlab.prf" in "C:\MATLAB_preferences ".
Check file permissions.
Cannot write to preference file "matlab.prf" in "C:\MATLAB_preferences ".
Check file permissions.
An error was encountered while saving the command history
java.io.FileNotFoundException: C:\MATLAB_preferences \History.xml (The system cannot find the path specified)
at java.io.RandomAccessFile.open0(Native Method)
at java.io.RandomAccessFile.open(RandomAccessFile.java:316)
at java.io.RandomAccessFile.<init>(RandomAccessFile.java:243)
at com.mathworks.mde.cmdhist.AltHistoryCollection$CommandSaver.run(AltHistoryCollection.java:1214)
at java.lang.Thread.run(Thread.java:748)
Please suggest the solution
1 Comment
Walter Roberson
on 21 Jul 2019
Check to see whether you have an environment variable named MATLAB_PREFDIR
Answers (2)
Gagandeep Sharma
on 21 Jul 2019
3 Comments
Walter Roberson
on 22 Jul 2019
At the MATLAB command window, please show the output of these two commands:
!echo %MATLAB_PREFDIR%
!echo %USERPROFILE%
!set
The ! are part of the commands.
Gagandeep Sharma
on 22 Jul 2019
2 Comments
Walter Roberson
on 22 Jul 2019
You consistently added a space to the command. I did not say
!echo %MATLAB_PREFDIR %
I said
!echo %MATLAB_PREFDIR%
exclamation-mark e c h o SPACE percent M A T L A B underscore P R E F D I R percent
not
exclamation-mark e c h o SPACE percent M A T L A B underscore P R E F D I R SPACE percent
Anyhow, the result of !set shows:
MATLAB_PREFDIR=C:\MATLAB_preferences
which is what we needed to know.
You should follow the directions at https://www.architectryan.com/2018/08/31/how-to-change-environment-variables-on-windows-10/ and DELETE the environment variable named MATLAB_PREFDIR
Note: if you are working on a corporate system, or working on a system set up by a university IT team, then you might possibly not have administrator access to change this variable, or the variable might be set by GROUP Policy. If so you might need to get the IT people to change the variable.
If changing the variable is not possible for some reason, then at the very least, someone with admin access should create the directory C:\MATLAB_preferences and give you write access.
If changing the variable is not possible, and creating that directory is not possible, then you should consider creating a .bat file that does
SET MATLAB_PREFDIR=
and then starts MATLAB.
See Also
Categories
Find more on Startup and Shutdown in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!