4

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

user68186
  • 33,360
Codezy
  • 141

4 Answers4

2

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

user68186
  • 33,360
2

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.

1

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.

https://askubuntu.com/a/1090671/52747

abalter
  • 367
0

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

  • Windows 10 Pro 18917 or higher (which allows WSL 2)
  • X410
  • Pengwin

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

  1. Setup WSL 2 (follow these steps)
  2. Open CMD:
    1. If you have already a distro installed you can see an list and version using wsl -l -v
    2. 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.
    3. (You might get prompted to install WSL 2 Linux kernel update. Follow the link and install the msi. Redo step 2)
    4. Make WSL 2 your default: wsl --set-default-version 2
  3. Install Pengwin from Store
  4. Restart Terminal
  5. After you installed Pengwin, launch it to setup your username/password
  6. Launch pengwin-setup. Select GUI, then GUILIB from the the Menu. And wait for installation to finish
  7. 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

  1. Open your WSL2-enabled Distro
  2. sudo apt update (optional)
  3. sudo apt -y upgrade (optional)

Install R

  1. sudo apt -y install r-base
  2. Verify by typing R in your terminal.
  3. R will run an interactive session. Quite with q()

Download/Install RStudio

  1. wget https://download1.rstudio.org/desktop/bionic/amd64/rstudio-1.2.5033-amd64.deb
  2. sudo apt -f install (required to install .deb files)
  3. sudo dpkg -i rstudio-1.2.5033-amd64.deb
  4. 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)

  1. sudo apt install libnss3
  2. sudo apt install libegl1-mesa

Restart terminal (twice, if prompted)

Install X410

  1. Install X410 from the store, then launch it.
  2. Right click X410 in system tray an click:
    1. Allow Public Access
    2. Windowed Apps (optional)
    3. DPI Scaling → High Quality (optional)

Launch RStudio

Open Pengin terminal and enter rstudio