11%% Finds the program "MathWorksUpdateInstaller" used to check for Matlab updates.
22%
3- % The usual MathWorksUpdateInstaller program was removed in R2025a.
4- % There is another program under the Mathworks ServiceHost, but folks have
5- % observed that program results in network error code 1804. Nonetheless, we
6- % give the location of that program, hoping that the Mathworks will make a
7- % solution, perhaps via "mpm upgrade" in the future.
3+ % The <matlabroot>/bin/<arch>/MathWorksUpdateInstaller program was removed in R2025a.
4+ % There was long a second copy under the ServiceHost directory that we use instead.
85%
96% future: programmatic update is planned for the "mpm" program:
107% https://github.com/mathworks-ref-arch/matlab-dockerfile/issues/129#issuecomment-2783047083
118%
12- % Ref: https://www.mathworks.com/matlabcentral/answers/1815365-how-do-i-uninstall-and-reinstall-the-mathworks-service-host
9+ % References:
10+ % * https://www.mathworks.com/matlabcentral/answers/2178694-mathworksupdateinstaller-and-r2025a-in-linux#answer_1568457
11+ % * https://www.mathworks.com/matlabcentral/answers/1815365-how-do-i-uninstall-and-reinstall-the-mathworks-service-host
1312
14- function MatlabReleaseUpgrade()
13+ function MatlabReleaseUpgrade(doUpgrade )
14+ arguments
15+ doUpgrade (1 ,1 ) logical = false
16+ end
1517
1618cmd = getUpgradePath();
1719
18- fprintf(" Matlab upgrade program found:\n\n%s\n\n" , cmd )
20+ fprintf(" Matlab upgrade command:\n\n%s\n\n" , cmd );
21+
22+ if doUpgrade
23+ s = system(cmd );
24+ assert(s == 0 )
25+ else
26+ disp(" MatlabReleaseUpgrade(1) to install upgrade" )
27+ end
1928
2029end
2130
@@ -30,28 +39,34 @@ function MatlabReleaseUpgrade()
3039end
3140
3241if isMATLABReleaseOlderThan(' R2025a' )
33- cmd = legacy_update_path(name );
42+ exe = legacy_update_path(name );
3443else
35- cmd = new_update_path(name );
44+ exe = new_update_path(name );
3645end
3746
38- if ~isfile(cmd )
39- error(" Did not find upgrade program at %s" , cmd )
47+ if ~isfile(exe )
48+ error(" Did not find upgrade program at %s" , exe )
4049end
4150
51+ if ismac()
52+ exe = " '" + exe + " '" ;
53+ end
54+
55+ cmd = sprintf(' %s --destination %s ' , exe , matlabroot );
56+
4257end
4358
4459
45- function cmd = legacy_update_path(name )
60+ function exe = legacy_update_path(name )
4661
4762r = fullfile(matlabroot , " bin" , computer(" arch" ));
4863mustBeFolder(r )
49- cmd = fullfile(r , name );
64+ exe = fullfile(r , name );
5065
5166end
5267
5368
54- function cmd = new_update_path(name )
69+ function exe = new_update_path(name )
5570
5671arch = computer(" arch" );
5772
@@ -64,8 +79,8 @@ function MatlabReleaseUpgrade()
6479elseif ispc()
6580 head = fullfile(getenv(" LOCALAPPDATA" ), ' MathWorks/ServiceHost' );
6681else
67- addpath(fileparts(fileparts(mfilename( ' fullpath ' ))))
68- head = fullfile(getenv(" HOME" ), ' .MathWorks/ServiceHost' , stdlib . hostname() );
82+ hostname = string(javaMethod( " getLocalHost " , " java.net.InetAddress " ).getHostName());
83+ head = fullfile(getenv(" HOME" ), ' .MathWorks/ServiceHost' , hostname );
6984end
7085mustBeFolder(head )
7186
@@ -84,6 +99,6 @@ function MatlabReleaseUpgrade()
8499fclose(fid );
85100mustBeNonempty(svcRoot )
86101
87- cmd = fullfile(svcRoot , bin_tail , name );
102+ exe = fullfile(svcRoot , bin_tail , name );
88103
89104end
0 commit comments