My laptop has the windows 10 system and I have installed the subsystem Ubuntu. I have installed Rstudio but when I run it "QXcbConnection: Could not connect to display Aborted (core dumped)" will be shown. Could anyone tell me how can I run Rstudio on my Linux subsystem? Thank you
4 Answers
WSL (Ubuntu) does not have a GUI!
The Windows Subsystem for Linux (WSL) is only command line. That means it can only run programs that have a text based interface. R for Linux is text based. Rstudio is a graphical user interface for R. You may be able to run R in WSL. I have not tried it.
However, without considerable tweaking it is not possible to run any software in WSL that needs a GUI. See What's the easiest way to run GUI apps on WSL as of 2018?
Both R and Rstudio is available for Windows. You may want to use those versions.
Hope this helps

- 33,360
Instead of running RStudio Desktop from the WSL, another option is to run RStudio Server from the WSL and access it in your web browser. This is straightforward to accomplish thanks to the OpenCPU project. I provide instructions for running RStudio Server from the WSL (as well as generally setting up the WSL for R development) in my blog post R programming in the Windows Subsystem for Linux.

- 121
- 3
By far the simplest, most direct way to run GUI applications from WSL is to use MobaXTerm as your terminal emulator. It also gives you mutiple tabs and other stuff.

- 367
Use RStudio within Windows Subsystem for Linux 2 (WSL 2)
Does WSL 1 work?
No, you will get cannot execute binary file: Exec format error
when you try to run rstudio
command.
Requirements / Limitations
Requirment
Limitations
- I only tested this with X410. Other x systems might work as well. However; compared to other X systems, it works very well with Hi-DPI systems, and it offers different displaying modes.
- As of now I only managed to get the GUI of RStudio running in Pengwin. A Linux distro tailor-made for WSL. I tried it for Ubuntu 18.04 — But I get stuck on the Error
WebEngineContext used before QtWebEngine::initialize() or OpenGL context creation failed
Detailed Error
WebEngineContext used before QtWebEngine::initialize() or OpenGL context creation failed.
Failed to create OpenGL context for format QSurfaceFormat(version 2.0, options QFlags<QSurfaceFormat::FormatOption>(), depthBufferSize 24, redBufferSize -1, greenBufferSize -1, blueBufferSize -1, alphaBufferSize -1, stencilBufferSize 8, samples 0, swapBehavior QSurfaceFormat::DefaultSwapBehavior, swapInterval 1, colorSpace QSurfaceFormat::DefaultColorSpace,
profile QSurfaceFormat::NoProfile)
Received signal 6
WSL 2 and Pengwin Setup
- Setup WSL 2 (follow these steps)
- Open CMD:
- If you have already a distro installed you can see an 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 an list and version using
- Install Pengwin from Store
- Restart Terminal
- After you installed Pengwin, launch it to setup your username/password
- Launch
pengwin-setup
. Select GUI, then GUILIB from the the Menu. And wait for installation to finish - Reopen terminal, and reopen again if prompted
Your Distro is now using WSL 2. FYI: You can access the file system by typing \\wsl$
in your windows explorer’s address bar
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 (Pengwin)
sudo apt install libnss3
sudo apt install libegl1-mesa
Restart terminal (twice, if prompted)
Install X410
- Install X410 from the store, then launch it.
- Right click X410 in system tray an click:
- Allow Public Access
- Windowed Apps (optional)
- DPI Scaling → High Quality (optional)
Launch RStudio
Open Pengin terminal and enter rstudio

- 101