Skip to content

Commit 367ba5f

Browse files
committed
script: upgrade works for R2025a too
1 parent 3931875 commit 367ba5f

File tree

1 file changed

+33
-18
lines changed

1 file changed

+33
-18
lines changed

scripts/MatlabReleaseUpgrade.m

Lines changed: 33 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,30 @@
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

1618
cmd = 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

2029
end
2130

@@ -30,28 +39,34 @@ function MatlabReleaseUpgrade()
3039
end
3140

3241
if isMATLABReleaseOlderThan('R2025a')
33-
cmd = legacy_update_path(name);
42+
exe = legacy_update_path(name);
3443
else
35-
cmd = new_update_path(name);
44+
exe = new_update_path(name);
3645
end
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)
4049
end
4150

51+
if ismac()
52+
exe = "'" + exe + "'";
53+
end
54+
55+
cmd = sprintf('%s --destination %s', exe, matlabroot);
56+
4257
end
4358

4459

45-
function cmd = legacy_update_path(name)
60+
function exe = legacy_update_path(name)
4661

4762
r = fullfile(matlabroot, "bin", computer("arch"));
4863
mustBeFolder(r)
49-
cmd = fullfile(r, name);
64+
exe = fullfile(r, name);
5065

5166
end
5267

5368

54-
function cmd = new_update_path(name)
69+
function exe = new_update_path(name)
5570

5671
arch = computer("arch");
5772

@@ -64,8 +79,8 @@ function MatlabReleaseUpgrade()
6479
elseif ispc()
6580
head = fullfile(getenv("LOCALAPPDATA"), 'MathWorks/ServiceHost');
6681
else
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);
6984
end
7085
mustBeFolder(head)
7186

@@ -84,6 +99,6 @@ function MatlabReleaseUpgrade()
8499
fclose(fid);
85100
mustBeNonempty(svcRoot)
86101

87-
cmd = fullfile(svcRoot, bin_tail, name);
102+
exe = fullfile(svcRoot, bin_tail, name);
88103

89104
end

0 commit comments

Comments
 (0)