Error in getDefaultUserFolder at MATLAB startup

27 次查看(过去 30 天)
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
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 个评论
Walter Roberson
Walter Roberson 2017-8-4
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.
Divyashree Tumakuru Ramesh
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 个)

类别

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