Error in getDefaultUserFolder at MATLAB startup

After a fresh install of 2012a I was welcomed by the following message:
Cannot find function, getDefaultUserFolder, in library services.
Warning: MATLAB did not appear to successfully set the search path. To recover for this session of
MATLAB, type "restoredefaultpath;matlabrc". To find out how to avoid this warning the next time you
start MATLAB, type "docsearch problem path" after recovering for this session.
Warning: Duplicate directory name: C:\Program Files\MATLAB\R2012a\toolbox\local.
Warning: Initializing Handle Graphics failed in matlabrc.
This indicates a potentially serious problem in your MATLAB setup,
which should be resolved as soon as possible. Error detected was:
MATLAB:undefinedVarOrClass
Undefined variable "graphics" or class "graphics.internal.initializeMATLABRoot".
Warning: Initializing Java preferences failed in matlabrc.
This indicates a potentially serious problem in your MATLAB setup,
which should be resolved as soon as possible. Error detected was:
MATLAB:UndefinedFunction
Undefined function 'usejava' for input arguments of type 'char'.
> In matlabrc at 113
Warning: Failed to add default profiler filters.
> In matlabrc at 168
Meaning that no paths was added and no MATLAB functions could be used. "restoredefaultpath" did make functions usable but gave warnings about duplicate directories. And matlabrc still gave warnings too. After restoring and saving the path, a reboot of MATLAB gave the same message. Even reinstalling MATLAB did not help.
At first everything was hopeless and it seemed nobody else had ever experienced this (from a google search). Has anybody else had this problem but not written about it?
I managed to find a solution finally, so I figured I should post it somehow. I guess an answer to my own question is the best way.

 채택된 답변

Marcus Björk
Marcus Björk 2012년 5월 31일

4 개 추천

So to the answer (skip to summary for quick solve). I figured there was something wrong with the user path since the first error mentioned this. The rest was probably only secondary failure.
In pathdef which is used by matlabrc userpath.m is called and inside user.m the call system_dependent('getuserworkfolder'); caused the message: "Cannot find function, getDefaultUserFolder, in library services." So setting the default path was a problem. I figured since you can change the user path it has to be stored somewhere, which turned out to be in AppData\Roaming\MathWorks\MATLAB\R2012a\matlab.settings (in win7). However the value is not stored there unless it has been changed it seems. But looking at the matlab.settings on a working installation, I could copy in a specified "userpath" value. This solved the problem! Hope this can help someone.
Summary:
change the userpath value maually in AppData\Roaming\MathWorks\MATLAB\R2012a\matlab.settings (or corresponding) to (or insert if missing):
<settings name="matlab" .....................................................>
<key name="UserPath">
<value><![CDATA[C:\Users\**\Documents\MATLAB]]></value>
</key>
or whatever user path you prefer (the dots correspond to some text I left out). Start MATLAB, enjoy.

댓글 수: 7

yu
yu 2012년 8월 30일
Good solution
I have the same problem
Thanks
Hello, I have the same problem and I can´t to find the direction: AppData\Roaming\MathWorks\MATLAB\R2012a\matlab.settings in matlab 2014
Jan
Jan 2017년 1월 25일
Open the Windows Explorer and type in the address field: "%APPDATA%" without the quotes. Can you find the file now?
You would probably need to change the R2012a to your version number.
The path exists on Windows 10 as well. But the the matlab.setting file is a SETTING file for me and I can not open it using MATLAB or other applications. How did you go about it? At the moment, I can not run a command line on MATLAB, for example writing 'help plot' in the command window only makes the error message pop up once again.
It is a text file. Open it with any text editor. If you need to, temporarily rename it to a file extension that your text editor will accept.
I am facing similar issue, when i opened the path, I have path only till AppData\Roaming\MathWorks\MATLAB\R2016b\ matlab.setting file is missing, how do i access that.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by