MATLAB: Do I see a “java.lang​.NullPoint​erExceptio​n” in the installation log when trying to install a support package

MATLAB

When trying to install a support package, the installation fails with the following error in the installation log:
java.lang.NullPointerException
Towards the beginning of the installation attempt, the log also contains:
Installation folder: null

Best Answer

The support package installation folder is not set or cannot be retrieved for some reason. The installation folder is saved in $MATLAB/toolbox/local/supportpackagerootsetting.xml. The file may not exist, not have read permissions or be invalid.
Run the following command to see if any errors are returned:
>> matlabshared.supportpkg.getSupportPackageRoot
Run the following to set an installation folder, then run the above again to verify if the folder was set properly:
>> matlabshared.supportpkg.setSupportPackageRoot('path_to_writable_location')
Replace "path_to_writable_location" with a valid path. Common locations are:
- Windows: C:\ProgramData\MATLAB\SupportPackages\<release>
- Linux: /home/<user>/Documents/MATLAB/SupportPackages/<release>
- Mac: /Users/<user>/Documents/MATLAB/SupportPackages/<release>
Alternatively, setting the contents of supportpackagerootsetting.xml to the following should work on all platforms:
<?xml version="1.0" encoding="UTF-8"?>
<SupportPackageRootSettings>
<Setting name="sproot">__DEFAULT__</Setting>
</SupportPackageRootSettings>