-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Suggestion for using R in WSL - run RStudio in WSL through a Linux graphical desktop #1
Comments
Hi @remlapmot! Thanks for reaching out. I'm definitely going to try this out. Depending on how it goes, I'll either update my previous post or create a new one. This Ask Ubuntu thread may interest you. They also discuss using an X11 client to use RStudio Desktop running in the WSL, but they used various other X11 clients. Have you tried either MobaXTerm or X410? |
Great @jdblischak . I haven't tried those other X11 clients but as far as I understand they basically have the same features. For example, VcXsrv can be run in windowed mode or (the whole Linux) desktop mode as well. If you write a batch file to launch your WSL with a graphical desktop / windowed mode you change the relevant X11 executable/ Another method - Docker Desktop using WSL 2 engineThere is sort of another method of running R/RStudio which involves WSL 2. Docker Desktop on Windows can use a WSL 2 engine. In Docker Desktop settings tick Enable the experimental WSL 2 based engine. You can launch any of the rocker, https://www.rocker-project.org/ containers. As the rocker main page says you can launch base R with
Or you can launch RStudio (I think server) with
You then access RStudio in your browser at http://localhost:8787 (username is RAM issue with WSL 2Another helpful point about WSL 2 is that it is useful to set the max amount of memory you want it to be able to use. Otherwise the |
@remlapmot Thanks again for all the advice and ideas. I recently returned to experimenting with my WSL1 setup, and I attempted to run RStudio in a graphical user interface. I successfully installed VcXsrv and was able to launch a graphical user interface. Unfortunately the only thing I couldn't get working was running RStudio. With versions 2022.02.1-461, 1.3.938 (the version you used in your instructions), and 1.2.5042, I get the following error:
From Issue rstudio/rstudio#3615, the advice is to try RStudio 1.1. But this fails to install due to a missing dependency (I vaguely recall running into this error years ago when it was first released, but I don't have much motivation to resurrect RStudio 1.1). Below is explicitly what I attempted. Are you currently able to run RStudio Desktop in WSL1? If yes, what version? Thanks! # 2022.02.1-461 - Exec format error
wget https://s3.amazonaws.com/rstudio-ide-build/desktop/bionic/amd64/rstudio-2022.02.1-461-amd64.deb
sudo gdebi rstudio-2022.02.1-461-amd64.deb
rstudio
# bash: /usr/bin/rstudio: cannot execute binary file: Exec format error
sudo apt remove rstudio
# 1.3.938 - Exec format error
wget https://s3.amazonaws.com/rstudio-ide-build/desktop/bionic/amd64/rstudio-1.3.938-amd64.deb
sudo gdebi rstudio-1.3.938-amd64.deb
rstudio
# bash: /usr/bin/rstudio: cannot execute binary file: Exec format error
sudo apt remove rstudio
# 1.2.5042 - Exec format error
wget https://download1.rstudio.org/desktop/trusty/amd64/rstudio-1.2.5042-amd64.deb
sudo gdebi rstudio-1.2.5042-amd64.deb
rstudio
# bash: /usr/bin/rstudio: cannot execute binary file: Exec format error
sudo apt remove rstudio
# 1.1.463 - missing libgstreamer0.10-0
wget https://download1.rstudio.org/rstudio-1.1.463-amd64.deb
sudo gdebi rstudio-1.1.463-amd64.deb
Reading package lists... Done
Building dependency tree
Reading state information... Done
Reading state information... Done
This package is uninstallable
Dependency is not satisfiable: libgstreamer0.10-0 |
For your missing libgstreamer error I found this page here. Maybe one of the answers will help? I have upgraded all my WSL instances to WSL version 2 - as WSL2 file system operations are noticeably faster than on WSL1. There are a few more things you can try. RStudio server - (I find most convenient)I now use RStudio server running on my WSL 2 but I interact with it using a browser in Windows. I can't remember if this was one your previous methods. To use RStudio server
Or go to Server Version section of one of their downloads pages, e.g. https://www.rstudio.com/products/rstudio/download/preview/
Electron version of RStudioFor the development versions of RStudio they have Electron builds on their dailies website https://dailies.rstudio.com/rstudio/spotted-wakerobin/electron/bionic/ https://dailies.rstudio.com/rstudio/spotted-wakerobin/electron/macos/ https://dailies.rstudio.com/rstudio/spotted-wakerobin/electron/windows/ You could try the bionic one. Certainly on macOS the Electron version opens noticeably faster than the usual build. Bundled graphical WSL appsInstead of installing the X11 stuff yourself Microsoft's WSLg and the GWSL app in the Microsoft Store appear to have bundled it up more conveniently |
@remlapmot Again, thanks for the very thorough answer! Electron dailes
I liked this idea, so I tried this first. I didn't have much luck. I finally got it to launch by specifying # WSL terminal
wget https://s3.amazonaws.com/rstudio-ide-build/electron/bionic/amd64/rstudio-2022.06.0-daily-270-amd64.deb
sudo gdebi rstudio-2022.06.0-daily-270-amd64.deb
# started xlaunch.exe
export DISPLAY=localhost:0
mate-session
# In MATE terminal
$ rstudio
[370:0406/094151.472708:FATAL:setuid_sandbox_host.cc(158)] The SUID sandbox helper binary was found, but is not configured correctly. Rather than run without sandboxing I'm aborting now. You need to make sure that /usr/lib/rstudio/chrome-sandbox is owned by root and has mode 4755.
Trace/breakpoint trap (core dumped)
[372:0100/000000.638758:ERROR:zygote_linux.cc(646)] write: Broken pipe (32)
$ ls -l /usr/lib/rstudio/chrome-sandbox
-rwxr-xr-x 1 root root 52536 Apr 5 00:47 /usr/lib/rstudio/chrome-sandbox
$ sudo rstudio
[0406/094307.885930:FATAL:electron_main_delegate.cc(292)] Running as root without --no-sandbox is not supported. See https://crbug.com/638180.
Trace/breakpoint trap (core dumped)
$ rstudio --no-sandbox
# window opens, but it is blank white
$ sudo rstudio --no-sandbox
# window opens, but it is blank white RStudio Server
Yep, exactly. My current approach is to use RStudio Server. I use the OpenCPU infrastructure to install and run RStudio Server, but other than that the approaches have the same effect. Microsoft Store
I don't have access to the Microsoft Store on my work laptop. That is one of the main reasons I have been hesitant to migrate to WSL2. It was a colossal pain to get WSL1 installed (compared to how easy it was via the Microsoft Store on my personal laptop). Missing libgstreamer
Yeah, this reminded me that I had old notes on how to fix this problem. I found my code for pinning old versions of libgstreamer with APT. This was from back in 2017. If I'm going to write a blog post advising people how to install RStudio Desktop in WSL, I don't want to use such outdated versions of libgstreamer and RStudio. If I can't get a more modern version working, it doesn't seem worth the trouble. |
In case helpful - you can upgrade WSL 1 instances to WSL 2 at the command line (but I don't know if this would need admin rights) https://docs.microsoft.com/en-us/windows/wsl/install#upgrade-version-from-wsl-1-to-wsl-2
|
Ah, nice! I'm going to give this a try on my personal laptop first. I'm too afraid of borking my work laptop. |
I have run it twice - it ran quickly without error both times! (definitely felt a bit nervous pressing Enter!) |
@remlapmot Thanks so much for taking the time to provide a detailed explanation of this useful option to install a graphical desktop in WSL, and for answering my questions. I finally got around to updating the blog post. I put a note right at the beginning that points to our discussion here |
thanks John - very nice of you; and very helpful additional links. |
I finally took the time to upgrade my WSL from v1 to v2. As I had feared, it was non-trivial. My laptop wasn't configured properly to support WSL2. Below are my summarized notes (for my future self and anyone else interested). PS C:\Users\john> wsl --status
Default Distribution: Ubuntu-18.04
Default Version: 2
WSL2 is not supported with your current machine configuration.
Please enable the "Virtual Machine Platform" optional component and ensure virtualization is enabled in the BIOS.
For information please visit https://aka.ms/enablevirtualization The first step in the link in the error message is to check the Hyper-V system requirements. This led me down a confusing rabbit hole because Hyper-V is not available for the Home edition of Windows 10/11. Fortunately it's not required. Next I followed these instructions to confirm that the BIOS setting "Intel Virtualization Technology" was already enabled. Then I ran the following line in PowerShell to enable the "Virtual Machine Platform" and restarted my laptop (instructions) dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart Only then was I able to migrate my existing WSL installation from v1 to v2 PS C:\WINDOWS\system32> wsl --set-version Ubuntu-18.04 2
For information on key differences with WSL 2 please visit https://aka.ms/wsl2
Conversion in progress, this may take a few minutes.
The operation completed successfully. So far everything is working well. I was also able to install a newer version of Ubuntu that also uses WSL v2. |
I really enjoyed your blog about running R on Ubuntu on WSL.
I don't know if this is the best way to contact you - anyway - there is another method you could include.
You can install a graphical desktop environment in WSL and then run the Ubuntu version of RStudio in there.
I have followed online which show how to install MATE desktop and KFCE4 desktop on WSL (I can't make GNOME 3 work), e.g. here.
Below is some more possibly helpful info:
gdebi
(changing the name of the .deb file as required)sudo
, e.g.sudo rstudio
, and it works (having made sure rstudio is on my$PATH
) (I guess not ideal running assudo
).cheers
Tom
The text was updated successfully, but these errors were encountered: