Begin with a plain Ubuntu distro from the Windows App Store. If one is already installed and you want to start from scratch simply:
wsl -t Ubuntu
wsl --unregister Ubuntu
Ubuntu
Then enter the user name and password and exit again.
Download the basic-wsl2-rstudio.sh
script to your Windows system and execute
wsl -d Ubuntu -u root -- ./basic-wsl2-rstudio.sh
Wait a few minutes (just under 5 on my system) and then
Ubuntu
rstudio &
If everything worked out you should be able to install binary packages from RStudio without issue. If you create a new markdown document then RStudio will prompt to download what you need.
Have fun!
Hi, just wanted to say thanks for this. I was able to get Rstudio up and running on my WSL2 with this, with a few extra steps. I thought I would post them here in case anyone else is having troubles.
The first thing I had to do was change the $DISPLAY environmental variable, because
ip r l default
returned the wrong ip (it returned my ethernet ip, whereas I needed my wifi ip). I had to find this manually in Windows withipconfig
, I think because I am using a USB wifi adaptor which WSL is not picking up.After fixing 1, I ended up with a window with a black screen when I ran
rstudio
. This turned out to be an issue with opengl. This was fixed by changing rstudio's settings to use 'software' rendering, instead of opengl. This is accomplished by opening~/.config/RStudio/desktop.ini
and adding a line like this:This solution is discussed in this rstudio issue: rstudio/rstudio#3185
I should also mention that I am using VcXsrv as my X server.
After I did this, everything is working great now. Thanks so much for the gist Thell!