jupyterhub / jupyter-rsession-proxy

Jupyter extensions for running an RStudio rsession proxy
BSD 3-Clause "New" or "Revised" License
118 stars 86 forks source link

RStudio launcher strangeness on Codespaces #144

Open syoh opened 7 months ago

syoh commented 7 months ago

Bug description

In Codespace, using jupyter-rsession-proxy to launch RStudio opens a window with a strange-looking URL.

For example,

Jupyter Lab URL: https://bookish-engine-7vjg45pq4xhpw4-8888.app.github.dev/lab RStudio launched URL: https://bookish-engine-7vjg45pq4xhpw4-8888.app.github.dev:8888/rstudio/auth-sign-in?appUri=%2F

How to reproduce

  1. Go to 'https://github.com/dddlab/rstudio/tree/update-jupyter-image'
  2. Start Codespaces
  3. image
  4. Get Jupyter server token with jupyter server list in terminal
  5. Click on Ports > RStudio row > globe icon
    image
  6. Login to Jupyter Lab with token
  7. Click on RStudio launcher button

Expected behaviour

Open RStudio

Actual behaviour

Your personal set up

Running on Codespaces with this Dockerfile: https://github.com/dddlab/rstudio/blob/update-jupyter-image/.devcontainer/Dockerfile

welcome[bot] commented 7 months ago

Thank you for opening your first issue in this project! Engagement like this is essential for open source projects! :hugs:
If you haven't done so already, check out Jupyter's Code of Conduct. Also, please try to follow the issue template as it helps other other community members to contribute more effectively. welcome You can meet the other Jovyans by joining our Discourse forum. There is also an intro thread there where you can stop by and say Hi! :wave:
Welcome to the Jupyter community! :tada:

ryanlovett commented 7 months ago

Hi @syoh , thanks for the clear instructions, as I was unfamiliar with starting jupyter in codespaces. I created a new codespace from your repo, and could confirm the problem. When I removed :8888 from the URL and tried again, I was redirected to a new page with the same issue. I removed :8888 a second time and that time I was properly directed to RStudio.

I was able to successfully launch RStudio properly from your main branch however. There were other changes in the repo, but I'm guessing it was probably due to the update of jupyter-rsession-proxy from 2.0.1 to 2.2.0.

syoh commented 7 months ago

Thank you @ryanlovett for taking the time to confirm the issue and the solution! I confirmed your solution works for me, too. Also, I confirmed that 2.1.0 also works fine, too. Hopefully that helps to narrow down the root cause.

eeholmes commented 1 month ago

Here are details on the behavior. Note, I tried to apply the patch but it did not help. I used this to apply the patch

pip install git+https://github.com/juzdzema/jupyter-rsession-proxy@patch-1

Changing the url 2x in the sequence below did work.

Here is what I have to do. Open a JupyterLab with jupyter-rsession-proxy. Click the RStudio button on the Launcher. For a moment, this url appears

https://crispy-space-memory-q97x6qjp59cx76p-8888.app.github.dev/rstudio

and then is replaced by this url

https://crispy-space-memory-q97x6qjp59cx76p-8888.app.github.dev:8888/rstudio/auth-sign-in?appUri=%2F

Remove the :8888 from the url and reload. That now looks like this

https://crispy-space-memory-q97x6qjp59cx76p-8888.app.github.dev/rstudio/auth-sign-in?appUri=%2F

That will now redirect to. Notice the :8888 reappears

https://crispy-space-memory-q97x6qjp59cx76p-8888.app.github.dev:8888/rstudio/

Now remove the :8888 again so url looks like

https://crispy-space-memory-q97x6qjp59cx76p-8888.app.github.dev/rstudio/

Now that url will work (not redirect) and clicking the button also works and will continue to work.

image
eeholmes commented 1 month ago

And here is my devcontainer.json. The py-rocket base image is just an image with JLab and RStudio.

{
  "name": "test",
  "workspaceFolder": "/home/jovyan",
  "image": "ghcr.io/nmfs-opensci/container-images/py-rocket-base:4.4-3.10",
  "hostRequirements": {
    "cpus": "2"
  },
  "customizations": {
    "vscode": {
      "extensions": [
        "ms-toolsai.jupyter",
        "ms-python.python",
      ]
    }
  },
  "forwardPorts": [
    8888
  ],
  "portsAttributes": {
    "8888": {
      "label": "Jupyter Lab - py-rocket-base",
      "onAutoForward": "openPreview"
    }
  },
  "postCreateCommand": "jupyter lab --ip=0.0.0.0 --port=8888 --allow-root --no-browser --NotebookApp.token='' --NotebookApp.password=''"
}
eeholmes commented 1 month ago

Update: it only occurs in a special case below with 2.2.0+ and not with 2.1.0.

I am running the Codespaces devcontainer with a Dockerfile with this line at the bottom. It is the same Dockerfile used in my JupyterHub.

EXPOSE 8888

CMD ["jupyter", "lab", "--ip=0.0.0.0", "--port=8888", "--allow-root", "--no-browser"]

The original poster was using this base image, which also exposes 8888 https://github.com/jupyter/docker-stacks/blob/main/images/base-notebook/Dockerfile

Using this image in a Codespace, doesn't automatically (for me at least) start jupyter lab on port 8888. Instead I run this from a terminal after the Codespace starts

jupyter lab --ip=0.0.0.0 --port=8888 --allow-root --no-browser --NotebookApp.token='' --NotebookApp.password=''

If I use --port=8888 I get the problem, but if I change to--port=8889, I don't.