This guide serves as a note to self to remember how to install MATLAB on a WSL virtual machine.
Ubuntu 20.04 on WSL2, with Windows 10.
Terminology
- host machine: the bare-metal Windows installation
- target machine: the WSL virtual machine
In this procedure, we are going to:
- Download the MATLAB installer for the host machine
- Using the installer on Windows, download the appropriate installation files for Linux
- Obtain a File License Key and download the License file from the MathWorks website
- Move all necessary files to WSL
- Create the
installer_input.txtfile to automate the installation process - Install MATLAB in WSL
The step of obtaining the License file and the File License Key requires to obtain a "Host ID". For Linux, this is the MAC address of the lowest enumerated ethernet device, which can be consulted by running
$ ifconfig- Obtain the MAC address of the WSL distro, by running
ifconfigin a terminal window. - Sign in to the MathWorks website.
- Go to the License Center.
- Select the "Install and Activate" tab.
- On the column on the right, click "View Current Activations"
- Click on the button "Activate a Computer"
- Select the Release you want, select the Linux OS, provide the Host ID obtained with
ifconfig, enter the Computer Login Name (your username in WSL), and enter an arbitrary (but appropriate) Activation Label. - Mark the radio button saying that MATLAB is not installed.
- Go to the Downloads page and download the installer for the host machine (i.e., Windows).
- Run the installer in Windows and sign in with your account.
- On the top right corner, in the Advanced Option dropdown, select "I want to download without installing".
- Proceed to select the appropriate options (e.g., the download folder, the target system---Linux---, the toolboxes you want to install---take a note of this)
- Once the download is over, open a terminal for WSL.
- Because the MATLAB downloader is bugged, we need to proceed in two steps.
mkdir ~/Downloads/matlab cd ~/Downloads/matlab cp /mnt/c/Users/<user>/Downloads/Mathworks/<release>/matlab_<release>_glnxa64.zip ./ unzip ./matlab_<release>_glnxa64.zip cp /mnt/c/Users/<user>/Downloads/Mathworks/<release>/archives/* ./archives -r
- Copy the file
installer_input.txtto the same location with a different name (for backup) and edit it following the instructions therein. - We are now ready to install MATLAB. MathWorks recommends to install to a user directory under user permissions.
mkdir -p ~/.matlab/<release> ./install -inputFile ./<your_installer_input>.txt
- The installer is silent, but it produces a log file for you to consult. At the end of that file, you should see indication of a successful install.
It works! Thank you for helping out