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.

 Réponse acceptée

Torsten
Torsten le 13 Oct 2026
Déplacé(e) : Torsten le 13 Oct 2026
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 commentaires

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 le 14 Oct 2026
Modifié(e) : Torsten le 14 Oct 2026
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.
Ningping Fan
Ningping Fan le 16 Oct 2026
Modifié(e) : Ningping Fan le 16 Oct 2026
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
Torsten
Torsten le 16 Oct 2026
Modifié(e) : Torsten le 16 Oct 2026
Creating a symbolic link is a nice solution.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Communications Toolbox dans Centre d'aide et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by