Cannot change support package to the "program files" directory

>> matlabshared.supportpkg.setSupportPackageRoot('C:\Program Files\MATLAB\SupportPackages');
Error using matlabshared.supportpkg.setSupportPackageRoot
Unable to set the support package root directory
Caused by:
Error using matlabshared.supportpkg.internal.SingleRootHandler.checkDirectory
The specified support package root folder name contains a space character.
Create or use a folder name that does not contain any space characters.
>> matlabshared.supportpkg.setSupportPackageRoot('C:\PROGRA~1\MATLAB\SupportPackages');
Error using matlabshared.supportpkg.setSupportPackageRoot
Unable to set the support package root directory
Caused by:
Error using matlabshared.supportpkg.internal.SingleRootHandler.checkDirectory
The specified support package root contains invalid characters.
Folder names can only contain alphanumeric characters, dashes and underscores.

 Accepted Answer

Torsten
Torsten on 13 Oct 2026 at 21:19
Moved: Torsten on 13 Oct 2026 at 21:21
Answer from AI:
The problem is that the MATLAB function matlabshared.supportpkg.setSupportPackageRoot strictly forbids spaces and special characters (including the tilde ~ used in Windows short paths) anywhere in the target folder path. [1, 2]
Here is exactly why both of your attempts failed:
  • First Attempt (C:\Program Files\...): It failed because "Program Files" contains a literal space character.
  • Second Attempt (C:\PROGRA~1\...): While using the Windows 8.3 short name removes the space, it introduces a tilde (~). The underlying MATLAB validation checks the string directly and considers the tilde an invalid special character, as it only permits alphanumeric characters, dashes, and underscores. [1, 2]
How to Fix It
To fix this, you must choose or create a path that has no spaces and no special characters. [1]
Option 1: Use the MATLAB Default Location (Recommended)
Unless you have a specific reason to change it, let MATLAB use its built-in default path, which is pre-configured to avoid these syntax errors. Run the function with no arguments to reset it: [1]
matlab
matlabshared.supportpkg.setSupportPackageRoot('default')
(On Windows, this typically maps to C:\ProgramData\MATLAB\SupportPackages, which does not contain spaces). [1]
Option 2: Create a Custom, Clean Directory
If you must host it elsewhere, create a brand-new folder directly on your drive root or in a clean user path, and ensure you run MATLAB as an Administrator to grant it write permissions: [1, 2]
matlab
% 1. Create a clean folder (e.g., C:\MATLAB_SupportPackages)
% 2. Point MATLAB to it:
matlabshared.supportpkg.setSupportPackageRoot('C:\MATLAB_SupportPackages');
If you still encounter problems, contact support:

4 Comments

I cannot use the default directory, because the company group policy does not allow an executable to run if it is not in the C:\Program Files\.... I wonder if the Matlab could set default directory to C:\Program Files\MATLAB\SupportPackages, instead of C:\ProgramData\MATLAB\SupportPackages
Torsten
Torsten on 14 Oct 2026 at 17:50
Edited: Torsten on 14 Oct 2026 at 18:03
My suggestion: Let the system administrator install the package in the default directory for you.
I doubt that MATLAB can (will) change "matlabshared.supportpkg.setSupportPackageRoot" for your purpose.
Solution is as follows:
  1. create a C:\MATLAB_Support_Packages
  2. mklink /J "C:\Program Files\MATLAB\SupportPackages\R2026b" "C:\MATLAB_Support_Packages" in cmd admin mode
  3. >> matlabshared.supportpkg.setSupportPackageRoot('C:\MATLAB_Support_Packages'); in MATLAB
  4. >> matlabshared.supportpkg.getSupportPackageRoot() in MATLAB to verify
Creating a symbolic link is a nice solution.

Sign in to comment.

More Answers (0)

Categories

Find more on Communications Toolbox in Help Center and File Exchange

Asked:

on 13 Oct 2026 at 20:59

Edited:

on 16 Oct 2026 at 14:53

Community Treasure Hunt

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

Start Hunting!