Not able to save toolbox folders to pathdef.m in MATLAB 2025b

72 views (last 30 days)
Hi,
I am running issues with the addon/toolbox path behaviour in MATLAB 2025b. My only other reference is MATLAB 2022b in which it works fine.
I have 2 toolboxes installed that I care about:
Name Version Enabled Identifier
_________________________________________ _________ _______ ______________________________________
"GUI Layout Toolbox" "2.3.5" true "e5af5a78-4a80-11e4-9553-005056977bd0"
"Widgets Toolbox" "1.3.330" true "b0bebf59-856a-4068-9d9c-0ed8968ac9e6"
When I launch MATLAB it's all ok and I see the folders needed in path:
C:\Users\username\AppData\Roaming\MathWorks\MATLAB Add-Ons\Toolboxes\Widgets Toolbox
C:\Users\username\AppData\Roaming\MathWorks\MATLAB Add-Ons\Toolboxes\Widgets Toolbox\demo
C:\Users\username\AppData\Roaming\MathWorks\MATLAB Add-Ons\Toolboxes\Widgets Toolbox\doc
C:\Users\username\AppData\Roaming\MathWorks\MATLAB Add-Ons\Toolboxes\Widgets Toolbox\doc\helpsearch-v3
C:\Users\username\AppData\Roaming\MathWorks\MATLAB Add-Ons\Toolboxes\Widgets Toolbox\resource
C:\Users\username\AppData\Roaming\MathWorks\MATLAB Add-Ons\Toolboxes\Widgets Toolbox\widgets
C:\Users\username\AppData\Roaming\MathWorks\MATLAB Add-Ons\Toolboxes\GUI Layout Toolbox\layout
C:\Users\username\AppData\Roaming\MathWorks\MATLAB Add-Ons\Toolboxes\GUI Layout Toolbox\layoutdoc
However, I when I use path(pathdef) to reset paths (which used to reset to the same state as at launch in my case), the folders for these toolboxes disappear.
I can see that they are not defined in pathdef.m, and if I call savepath after launching MATLAB, these folders will not get saved even if they are on the path, because for some reason they are in the ExcludePathStore list:
>> matlab.internal.path.ExcludedPathStore.getCurrentExcludeList()'
ans =
8×1 string array
"C:\Users\username\AppData\Roaming\MathWorks\MATLAB Add-Ons\Toolboxes\Widgets Toolbox"
"C:\Users\username\AppData\Roaming\MathWorks\MATLAB Add-Ons\Toolboxes\Widgets Toolbox\demo"
"C:\Users\username\AppData\Roaming\MathWorks\MATLAB Add-Ons\Toolboxes\Widgets Toolbox\doc"
"C:\Users\username\AppData\Roaming\MathWorks\MATLAB Add-Ons\Toolboxes\Widgets Toolbox\doc\helpsearch-v3"
"C:\Users\username\AppData\Roaming\MathWorks\MATLAB Add-Ons\Toolboxes\Widgets Toolbox\resource"
"C:\Users\username\AppData\Roaming\MathWorks\MATLAB Add-Ons\Toolboxes\Widgets Toolbox\widgets"
"C:\Users\username\AppData\Roaming\MathWorks\MATLAB Add-Ons\Toolboxes\GUI Layout Toolbox\layout"
"C:\Users\username\AppData\Roaming\MathWorks\MATLAB Add-Ons\Toolboxes\GUI Layout Toolbox\layoutdoc"
so my question is - is there a way to replace path(pathdef) with something that includes the toolbox folders as on MATLAB startup? I can find the install paths of the addons but with genpath it would end up including more folders than needed.
I could use matlab.internal.path.ExcludedPathStore.getCurrentExcludeList() to add them but not sure if that's the best approach as it's an internal class with no documentation that I could find.
  5 Comments
Steven Lord
Steven Lord on 4 Oct 2025 at 16:20
I was having a little trouble responding to this post on my machine yesterday, but the problem seems to have subsided.
Rather than manually trying to control the path yourself, if you're working on projects that include lots of files where each project needs a different subset of directories to be on the path I'd consider using the Projects functionality included in MATLAB. This will handle adding directories to the path when you start working on a project and restoring the path to its previous state (note this is different than either "removing directories from the path" or "restoring the path to its default") when you stop working on that project and/or switch to working on a different project.
dpb
dpb on 4 Oct 2025 at 22:02
So, can you expound some on the "why" behind this, Steven, and what determines which TB files will/will not be on the list and why?

Sign in to comment.

Accepted Answer

Titas Bucelis
Titas Bucelis on 4 Oct 2025 at 12:48
So looks like matlab.internal.path.ExcludedPathStore gets populated when addon is enabled (which I assume happens at startup), so I figured 3 ways to re-add addon paths:
  1. For my use case I am going to go with this at the moment: use matlab.internal.path.ExcludedPathStore.getCurrentExcludeList() which I haven't seen used anywhere else yet so hoping that addon paths are the only use
if ~isMATLABReleaseOlderThan("R2025b")
% Not sure what the oldest version needing this is, but in 2022b this
% is not needed and will break (no getCurrentExcludeList() method)
addpath(strjoin(matlab.internal.path.ExcludedPathStore.getCurrentExcludeList(), ';'), '-end');
end
  • Re-enable each addon using for example `matlab.addons.enableAddon('Widgets Toolbox')
addons = matlab.internal.addons.getAddonInstallations();
for addon = addons
matlab.addons.enableAddon(addon.Name);
end
  • Get paths of each addon from the addons cache, but I found this to be really slow when you first call it after MATLAB restart (7s)
installedAddonsCache = com.mathworks.addons_common.notificationframework.InstalledAddOnsCache.getInstance;
addons = matlab.internal.addons.getAddonInstallations();
if ~isempty(addons)
addons = addons([addons.Enabled]);
for identifier = [addons.Identifier]
installedAddon = installedAddonsCache.retrieveAddOnWithIdentifier(identifier);
addon_paths = string(installedAddon.getCustomMetadataWithAttributeName('matlabPathEntries').getValue());
addpath(strjoin(addon_paths, ';'),'-end')
end
end
  3 Comments
Titas Bucelis
Titas Bucelis on 4 Oct 2025 at 14:19
@dpb good suggestion! Although I have no idea if the behaviour for how addon paths are handled has changed at the same time. It's probably a good assumption as for example 2022b uses matlab.internal.language.ExcludedPathStore instead
dpb
dpb on 4 Oct 2025 at 22:11
Well, that doesn't help, it turns out because on R2022b exist can't find the hidden/private file as it does on R2025. Nor can which so one would have to do an exhaustive file search to locate it.
I never have built anything large enough that seemed to justify a project; it appears to have been introduced in R2019a but R2019b doesn't incorporate it yet, so still not at all clear as to why it was introduced. As you note, it appeared by R2021b in the +language folder as well as R2022b, the latest version I've installed so far.

Sign in to comment.

More Answers (0)

Categories

Find more on Search Path in Help Center and File Exchange

Products


Release

R2025b

Community Treasure Hunt

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

Start Hunting!