|
| 1 | +# File: contributing/wsl_debian_setup.org |
| 2 | + |
| 3 | +# | Copyright 2025 Free Software Foundation, Inc. |
| 4 | +# | |
| 5 | +# | This program is free software: you can redistribute it and/or modify |
| 6 | +# | it under the terms of the GNU General Public License as published by |
| 7 | +# | the Free Software Foundation, either version 3 of the License, or |
| 8 | +# | (at your option) any later version. |
| 9 | +# | |
| 10 | +# | This program is distributed in the hope that it will be useful, |
| 11 | +# | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | +# | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | +# | GNU General Public License for more details. |
| 14 | +# | |
| 15 | +# | You should have received a copy of the GNU General Public License |
| 16 | +# | along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 17 | + |
| 18 | +#+startup: showall |
| 19 | + |
| 20 | +#+html_head_extra: <link rel="stylesheet" type="text/css" href="css/styles-from-org.css"/> |
| 21 | +#+html_head_extra: <link rel="stylesheet" type="text/css" href="css/styles.css"/> |
| 22 | +#+options: ^:{} |
| 23 | +#+options: toc:nil |
| 24 | +#+latex_header: \usepackage[margin=0.5in]{geometry} |
| 25 | +#+latex_header: \usepackage{parskip} |
| 26 | +#+latex_header: \usepackage{tocloft} |
| 27 | +#+latex_header: \advance\cftsecnumwidth 0.5em\relax |
| 28 | +#+latex_header: \advance\cftsubsecindent 0.5em\relax |
| 29 | +#+latex_header: \advance\cftsubsecnumwidth 0.5em\relax |
| 30 | + |
| 31 | +#+title: Linux and Windows Emacs MATLAB Mode development using wsl |
| 32 | +#+author: John Ciolfi |
| 33 | +#+date: Jul-16-2026 |
| 34 | + |
| 35 | +To work on Emacs MATLAB Mode, it's helpful to have both Linux and Windows. If you have a Windows |
| 36 | +system, you can leverage Windows Subsystem for Linux, wsl, to install Debian alongside Windows. |
| 37 | +This guide is a template, and may will need adjustments for your environment or updates as systems |
| 38 | +evolve. |
| 39 | + |
| 40 | +[[https://www.mathworks.com/matlabcentral/answers/1881447-can-i-use-matlab-or-other-mathworks-products-with-windows-subsystem-for-linux-wsl-wsl2][MATLAB is not offically supported under wsl]], so MATLAB may not run correctly under wsl. For |
| 41 | +me, MATLAB R2025a ran well enough to leverage it in Emacs matlab-shell. |
| 42 | + |
| 43 | +1. Install wsl. The first time you install wsl, you will need to do the following, reboot, then |
| 44 | + redo it: |
| 45 | + |
| 46 | + : wsl --install -d Debian |
| 47 | + |
| 48 | +2. Launch wsl in a Command Window |
| 49 | + |
| 50 | + #+begin_src bash |
| 51 | + C:\> wsl ~ |
| 52 | + C:\> wsl -d Debian --cd ~ # Alternative to specify the distribution |
| 53 | + $ cat /etc/debian_version |
| 54 | + 12.11 |
| 55 | + #+end_src |
| 56 | + |
| 57 | + You can create a shortcut on your Windows desktop by right-click, new Shortcut |
| 58 | + and for the location, specify =C:\Windows\system32\wsl.exe ~= |
| 59 | + |
| 60 | +3. Install packages |
| 61 | + |
| 62 | + Noice we are installing emacs from Debian 12 backports to get Emacs 30.1 |
| 63 | + |
| 64 | + #+begin_src bash |
| 65 | + sudo apt update |
| 66 | + sudo apt upgrade |
| 67 | + sudo apt install zip |
| 68 | + sudo apt install man |
| 69 | + sudo apt install git |
| 70 | + sudo apt install -t bookworm-backports emacs |
| 71 | + sudo apt install chromium |
| 72 | + #+end_src |
| 73 | + |
| 74 | + We need a bunch of packages to be able to install MATLAB. See this [[https://www.mathworks.com/matlabcentral/answers/2018166-what-dependencies-are-needed-to-install-matlab-on-minimal-or-core-linux-installations][MATLAB Answers post]]. The |
| 75 | + packages we need for R2025a are listed in [[https://github.com/mathworks-ref-arch/container-images/tree/main/matlab-deps][matlab-deps]] navigate to [[https://github.com/mathworks-ref-arch/container-images/blob/main/matlab-deps/r2025a/ubuntu24.04/base-dependencies.txt][base-dependencies.txt]] then |
| 76 | + create an apt install command. I used this [[https://askubuntu.com/questions/445487/what-debian-version-are-the-different-ubuntu-versions-based-on][site]] to map Debain 12 to Ubuntu 22 which for the |
| 77 | + base_dependencies.txt. Alternatively, I suppose I could have used wsl to install Ubuntu, but I |
| 78 | + have familiarity with Debian, so choose Debian. |
| 79 | + |
| 80 | + #+begin_src bash |
| 81 | + sudo apt install ca-certificates ibverbs-providers libasound2 libatomic1 libc6 libcairo-gobject2 libcairo2 libcap2 libcrypt1 libcups2 libdrm2 libfontconfig1 libfribidi0 libgbm1 libgdk-pixbuf-2.0-0 libgl1 libglib2.0-0 libgstreamer-plugins-base1.0-0 libgstreamer1.0-0 libgtk-3-0 libibverbs1 libice6 libltdl7 libnspr4 libnss3 libnuma1 libpam0g libpango-1.0-0 libpangocairo-1.0-0 libpangoft2-1.0-0 libpixman-1-0 libpsm2-2 librdmacm1 libsndfile1 libtirpc3 libucx0 libuuid1 libwayland-client0 libxcomposite1 libxcursor1 libxdamage1 libxfixes3 libxfont2 libxft2 libxinerama1 libxrandr2 libxt6 libxtst6 libxxf86vm1 locales locales-all make net-tools procps sudo unzip wget x11-xkb-utils zlib1g |
| 82 | + #+end_src |
| 83 | + |
| 84 | + If you don't install these dependencies, the R2025a matlab install script may silently fail. |
| 85 | + |
| 86 | +4. Setup git |
| 87 | + |
| 88 | + #+begin_src bash |
| 89 | + git config --global user.email " [email protected]" |
| 90 | + git config --global user.name "Your Name" |
| 91 | + #+end_src |
| 92 | + |
| 93 | +5. Install MATLAB R2025a |
| 94 | + |
| 95 | + From http://www.mathworks.com, download R2025a linux zip file and unzip. I unzipped it to |
| 96 | + =~/matlab-installs/R2025a.u0.install/=, where in my terminology u0 is the first release (update |
| 97 | + 0). |
| 98 | + |
| 99 | + #+begin_src bash |
| 100 | + cd ~/matlab-installs/R2025a.u0.install |
| 101 | + ./install |
| 102 | + #+end_src |
| 103 | + |
| 104 | + After typing ./install, a "MathWorks Product Installer" window will appear and you |
| 105 | + can enter your Email, then continue to follow the installation instructions. Note, I installed |
| 106 | + it in =~/matlab-installs/R2025a.u0= instead of the standard location. |
| 107 | + |
| 108 | + I then ran matlab |
| 109 | + |
| 110 | + #+begin_src |
| 111 | + ~/matlab-installs/R2025a.u0/bin/matlab |
| 112 | + #+end_src |
| 113 | + |
| 114 | + and saw this error: |
| 115 | + |
| 116 | + : /home/USER/.MathWorks/ServiceHost/-mw_shared_installs/v2025.2.2.1/mci/bin/glnxa64/InstallMathWorksServiceHost: error while loading shared libraries: libgtk-x11-2.0.so.0: cannot open shared object file: No such file or directory |
| 117 | + |
| 118 | + I then: |
| 119 | + |
| 120 | + #+begin_src bash |
| 121 | + sudo apt update |
| 122 | + sudo apt install libgtk2.0-0 |
| 123 | + #+end_src |
| 124 | + |
| 125 | + I then re-ran matlab: |
| 126 | + |
| 127 | + #+begin_src |
| 128 | + ~/matlab-installs/R2025a.u0/bin/matlab |
| 129 | + #+end_src |
| 130 | + |
| 131 | + The MATLAB desktop appeared and ">> plot(1:10)" worked as expected. |
| 132 | + |
| 133 | +6. Add matlab to the PATH |
| 134 | + |
| 135 | + Assuming you are using the bash shell (the default), add to ~/.bashrc |
| 136 | + |
| 137 | + #+begin_src bash |
| 138 | + # pathAdd /path/to/dir - adds /path/to/dir to end of PATH if not already present |
| 139 | + pathAdd() { |
| 140 | + if [ -d "$1" ] && [[ ":$PATH:" != *":$1:"* ]]; then |
| 141 | + PATH="${PATH:+"$PATH:"}$1" |
| 142 | + fi |
| 143 | + } |
| 144 | + |
| 145 | + pathAdd $HOME/matlab-installs/R2025a.u0/bin |
| 146 | + #+end_src |
| 147 | + |
| 148 | + you'll want to do this for non-interactive and interactive shells. Generally, you place |
| 149 | + the above before the following in your ~/.bashrc |
| 150 | + |
| 151 | + #+begin_src bash |
| 152 | + # If not running interactively, don't do anything |
| 153 | + case $- in |
| 154 | + ,*i*) ;; |
| 155 | + ,*) return;; |
| 156 | + esac |
| 157 | + #+end_src |
| 158 | + |
| 159 | +7. Working in a git Emacs-MATLAB-Mode work-tree: |
| 160 | + |
| 161 | + #+begin_src bash |
| 162 | + cd ~/emacs-projects # some working area |
| 163 | + git clone https://github.com/mathworks/Emacs-MATLAB-Mode.git |
| 164 | + #+end_src |
| 165 | + |
| 166 | + Install =~/.emacs.d/tree-sitter/libtree-sitter-matlab.so= by grabbing matlab.so from |
| 167 | + https://github.com/emacs-tree-sitter/tree-sitter-langs latest release and renaming it |
| 168 | + to =~/.emacs.d/tree-sitter/libtree-sitter-matlab.so= |
| 169 | + |
| 170 | + #+begin_src bash |
| 171 | + cd Emacs-MATLAB-Mode |
| 172 | + make |
| 173 | + #+end_src |
| 174 | + |
| 175 | + Note, in wsl, you can access Windows file system, e.g. to access C:\Users\YourName use |
| 176 | + /mnt/c/Users/YourName. You could place the git work-tree under that, but I don't recommend it |
| 177 | + because of performance and git issues. Rather have one git work-tree in the Linux side and |
| 178 | + another on the Windows side in different places. You can then push/pull as you like between these |
| 179 | + via origin/some-branch. |
| 180 | + |
| 181 | +8. Set the Emacs title to show if you are using Linux or Windows. Add to your ~/.emacs: |
| 182 | + |
| 183 | + #+begin_src emacs-lisp |
| 184 | + (setq frame-title-format (concat "%b - Emacs " (symbol-name system-type))) |
| 185 | + #+end_src |
| 186 | + |
| 187 | +9. In your ~/.emacs, add your Emacs-MATLAB-mode git work-tree to the beginning of the |
| 188 | + load-path and load it: |
| 189 | + |
| 190 | + #+begin_src emacs-lisp |
| 191 | + (add-to-list 'load-path (concat "HOME" "emacs-projects/Emacs-MATLAB-mode")) |
| 192 | + (load-library "matlab-autoload") |
| 193 | + #+end_src |
| 194 | + |
| 195 | +10. Run MATLAB in Emacs: |
| 196 | + |
| 197 | + : M-x matlab-shell |
| 198 | + |
| 199 | + |
| 200 | + |
| 201 | + |
0 commit comments