Install and use RStudio within Windows Subsystem for Linux 2 (WSL 2)
💡 Does WSL 1 work?
No, you will get can not execute binary file: Exec format error
when you try to run rstudio
command.
Requirements / Limitations
Requirment
WSL 2 and Pengwin Setup
- Setup WSL 2 (follow these steps)
- Open CMD:
- If you have already a distro installed you can see a list and version using
wsl -l -v
- If you have already a WSL 1 distro installed, you can convert it to WSL 2:
wsl --set-version <DistroName> 2
. This will take some time. - (You might get prompted to install WSL 2 Linux kernel update. Follow the link and install the msi. Redo step 2)
- Make WSL 2 your default:
wsl --set-default-version 2
- If you have already a distro installed you can see a list and version using
- Install Pengwin from Store and launch Terminal
- Restart Terminal, you get prompted to do so
- After you installed Pengwin, launch it to setup your username/password
- Launch
pengwin-setup
. Select GUI, then GUILIB from the Menu. And wait for the installation to finish - Reopen terminal, and reopen again if prompted (this will apply guilib changes)
Install R and RStudio
- Open your WSL2-enabled Distro
sudo apt update
(optional)sudo apt -y upgrade
(optional)
Install R
sudo apt -y install r-base
- Verify by typing
R
in your terminal. - R will run an interactive session. Quite with
q()
Download/Install RStudio
wget https://download1.rstudio.org/desktop/bionic/amd64/rstudio-1.2.5033-amd64.deb
sudo apt -f install
(required to install .deb files)sudo dpkg -i rstudio-1.2.5033-amd64.deb
- If you get an error, try running step 2 again, and then step 3. I don’t know why, but that worked for me, after step 3 initially raised an error.
### Install other GUI dependencies
1.
sudo apt install libnss3
2. sudo apt install libegl1-mesa
Restart terminal (twice, if prompted)
These two packages were added in 355a245. You don’t need to install these anymore.
Install X410
- Install X410 from the store, then launch it.
- Right-click X410 in system tray a click:
- Allow Public Access
- Windowed Apps (optional)
- DPI Scaling → High Quality (optional)
Launch RStudio
Open Pengwin terminal and enter rstudio
Author: @Kalaschnik Steven Kalinke