[SOLVED] Latest RStudio will not work with JupyterHub or Binder, use R version 4.0

This is a general PSA because I’ve seen a few different JupyterHub deployments get burned by this recently. The goal of this post is just to tie together a few issues, provide cross-links, and maybe help point folks in the right direction.

The rsession proxy project is what makes it possible for people to run RStudio on a JupyterHub. This is used by JupyterHub and Binder.

The problem with updating RStudio

However, the latest version of RStudio introduced a bug that that breaks the redirection, as documented in this issue:

and discussed re: Binder here:

This bug is documented in this RStudio issue:

but thus far it seems like it won’t be a priority for them to fix for some time.

The problem with updating R 4.1

If you pin RStudio to 4.0, and continue updating the base R version, you’ll get an error about visualizations not working in RStudio and the visualizations won’t work. See this issue for one example of this problem:

What to do

Right now, there is no workaround that I know of for getting RStudio 4.1 to work on JupyterHub until [rserver auth redirect doesn't use www root path when X-Forwarded-Proto is set · Issue #8888 · rstudio/rstudio · GitHub] is resolved.

Your best bet is to pin R to v 4.0, that way an old version of RStudio works properly.

This issue discusses this in some detail, but it’s unclear to me what is the right path forward there: Pinning R 4.0 with runtime.txt on mybinder.org not working as expected · Issue #1077 · jupyterhub/repo2docker · GitHub

Do you know any other workarounds?

I know that’s not ideal - if anybody knows of another workaround for either JupyterHub or Binder please do share! We should update this thread if there’s a better solution that comes up.

1 Like

Hi @choldgraf thanks for raising this issue. In broad terms: I agree with your suggestion to use older versions of R for now, that seems to work for our newly updated Binder instance of the open source book Geocomputation with R: Binder

To see how I got this working again, see the .binder file of the associated repo.
Key to that approach is putting the following in environment.yml which uses the ‘r-conda’ version of R which is behind the latest version of R it seems:

name: geocompr
channels:
  - conda-forge
  - bioconda
  - r
dependencies:
  - r-base

A couple of questions:

  1. Is that stable and any ideas when ‘r-base’ in that set-up will switch?

  2. Could using a different graphics driver solve the issue? I’m thinking of ragg

1 Like

Here’s the code. Any comments on this welcome, I’m not sure if the ‘start’ file is needed… geocompr/.binder at main · Robinlovelace/geocompr · GitHub

A solution to this problem would be very much appreciated.
I successfully checked on https://mybinder.org/
Redirect client to auth-sign-in when not authenticated by ryanlovett · Pull Request #107 · jupyterhub/jupyter-rsession-proxy · GitHub .
I hope this could provide some insights.

jupyter-rsession-proxy version 2.0 fixes this! So latest RStudio now works again with jupyterhub. See A template repository for running latest RStudio + R on mybinder.org / your JupyterHub for an example.

You’ll need to make sure you’re on R 4.1, and jupyter-rsession-proxy >= 2.0.

Massive thanks to @ryanlovett and maresb for making this happen!

3 Likes

Amazing - thanks to all the folks that helped make this happen :heart:

Hello, I am getting a problem that could be related with this, I am using jupyterhub on kubernetes and when I build an image using older R version, it works correctly: I login to jupyterhub, a jupyterlab instance is launched and I can from there launch Rstudio and it appears in another tab as expected.

But when I try building an image with R 4.1 or greater, when I select Rstudio from the options on jupyterlab launch menu, it redirects to “https://access/user/\<my username>/rstudio/auth-sign-in?appUri=%2F” and page not found error appears on the browser.

I checked and I am using jupyter-rsession-proxy version 2.0.1 on the single user image, this is from the jupyterlab terminal:

luciano@jupyter:~$ pip show jupyter-rsession-proxy
Name: jupyter-rsession-proxy
Version: 2.0.1
Summary: Jupyter extension to proxy RStudio
Home-page: https://github.com/jupyterhub/jupyter-rsession-proxy
Author: Ryan Lovett & Yuvi Panda
Author-email: UNKNOWN
License: UNKNOWN
Location: /srv/conda/envs/notebook/lib/python3.7/site-packages
Requires: jupyter-server-proxy
Required-by: 

Probably I am missing something, but I cant find the issue.
If someone knows what I am doing wrong, maybe can help me

Thanks in advance!
Luciano

1 Like

Sorry, Its not solved, in my case

Having the same issue here. Using a daily build since JupyterLab images are on jammy: Ubuntu 22.

I have had this issue for the past 1.5 half years. I read this thread and found the solution for my issue: Problems running Rstudio on JupyterHub - #5 by Miklos_Harsszegi

My setup uses the jupyter/datascience-notebook:ubuntu-20.04 as the base image + RStudio version 2023.09.1-494, for Ubuntu Focal. The server running this Jupyterhub instance did not have any domain named assigned, so I was accessing Jupyterhub through a URL formatted like this:

https://10.0.12.104/jupyter/user/testuser/lab

When I tried to access RStudio, I would get redirected to this URL:

http://10.0.12.104/jupyter/user/testuser/rstudio/auth-sign-in?appUri=%2F

Removing the auth-sign-in?appUri=%2F and changing the URL to use https instead of http would still not work, as it would continue to redirect me to the above incorrect URL.
After reading this thread, I assigned two DNS names to the same server:

  1. https://abc.xyz.com
  2. https://abc-def.xyz.com

When accessing the Jupyterhub instance through URL 1), this would redirect me to the correct URL when opening RStudio server:

https://abc.xyz.com/jupyter/user/testuser/rstudio

And RStudio works as normal. But when accessing through URL 2), I would get the same error that I got when accessing with the IP address:

http://abc-def.xyz.com/jupyter/user/testuser/rstudio/auth-sign-in?appUri=%2F

So the current fix (at least for my case), is to access Jupyterhub through a URL that has no - character or IP addresses. Hoping for a fix.

Edit:
Upon further investigation, this might turn out to be also related to not having a valid TLS certificate. URL 2) works now too after a valid TLS certificate was deployed alongside Jupyterhub and it now redirects me to https://abc-def.xyz.com/jupyter/user/testuser/rstudio without any issues.
@yuvipanda @jrdnbradford

Thank you,
Stefano

1 Like