Skip to content

Instantly share code, notes, and snippets.

@AndreaPasqualini
Last active July 11, 2024 08:23
Show Gist options
  • Save AndreaPasqualini/e9737fe7d4abb88c9477b31dece17bb3 to your computer and use it in GitHub Desktop.
Save AndreaPasqualini/e9737fe7d4abb88c9477b31dece17bb3 to your computer and use it in GitHub Desktop.
Instructions to install MATLAB on WSL

Installing MATLAB on WSL

This guide serves as a note to self to remember how to install MATLAB on a WSL virtual machine.

Environment

Ubuntu 20.04 on WSL2, with Windows 10.

Overview of Instructions

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.txt file 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

Step-by-Step Guide

  1. Obtain the MAC address of the WSL distro, by running ifconfig in a terminal window.
  2. Sign in to the MathWorks website.
  3. Go to the License Center.
    1. Select the "Install and Activate" tab.
    2. On the column on the right, click "View Current Activations"
    3. Click on the button "Activate a Computer"
    4. 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.
    5. Mark the radio button saying that MATLAB is not installed.
  4. Go to the Downloads page and download the installer for the host machine (i.e., Windows).
  5. Run the installer in Windows and sign in with your account.
  6. On the top right corner, in the Advanced Option dropdown, select "I want to download without installing".
  7. 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)
  8. Once the download is over, open a terminal for WSL.
  9. 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
  10. Copy the file installer_input.txt to the same location with a different name (for backup) and edit it following the instructions therein.
  11. 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
  12. 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.
@andrybicio
Copy link

It works! Thank you for helping out

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment