coder / code-server

VS Code in the browser
https://coder.com
MIT License
67.7k stars 5.55k forks source link

[Bug]: Jupyter Notebook not working #4777

Closed vdallavalle closed 2 years ago

vdallavalle commented 2 years ago

Is there an existing issue for this?

OS/Web Information

- Web Browser: Chrome
- Local OS: Any 
- Remote OS: Docker (Unraid OS)
- Remote Architecture: AMD x64
- `code-server --version`: 4.0.1

Expected

[Notebook Creation]: Creation and opening of new .ipynb file with proper layout as shown in MS documentation [Notebook Opening]: Opening .ipynb file should result in proper layout shown with possibility of editing the notebook file.

Actual

[Notebook Creation]: Error message "Command 'Jupyter: Create New Jupyter Notebook' resulted in an error (NO provider registered for view type: 'jupyter-notebook')", no file being created, black screen. [Notebook Opening]: Error message "Cannot open resource with notebook editor type 'jupyter-notebook', please check if you have the right extension installed or enabled.", file content not shown, black screen.

Logs

In the following, the Chrome console output related to the situations mentioned above

[Notebook Creation]:

(node:11546) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.(Use `node --trace-deprecation ...` to show where the warning was created)

...

mainThreadExtensionService.ts:95 Activating extension 'vscode.ipynb' failed: Cannot find module '/usr/local/share/.config/yarn/global/node_modules/code-server/vendor/modules/code-oss-dev/extensions/ipynb/dist/ipynbMain.js'
Require stack:
- /usr/local/share/.config/yarn/global/node_modules/code-server/vendor/modules/code-oss-dev/out/vs/loader.js
- /usr/local/share/.config/yarn/global/node_modules/code-server/vendor/modules/code-oss-dev/out/bootstrap-amd.js
- /usr/local/share/.config/yarn/global/node_modules/code-server/vendor/modules/code-oss-dev/out/bootstrap-fork.js.

...

CRITI FAILED to destory notebook Error: NO provider registered for view type: 'jupyter-notebook'
    at O.withNotebookDataProvider (notebookServiceImpl.ts:611:10)
    at async u.createReferencedObject (notebookEditorModelResolverServiceImpl.ts:64:16)
    at async a.resolve (notebookEditorModelResolverServiceImpl.ts:216:18)
    at async l.$tryCreateNotebook (mainThreadNotebookDocuments.ts:131:15)

[Notebook Opening]:

mainThreadExtensionService.ts:95 Activating extension 'vscode.ipynb' failed: Cannot find module '/usr/local/share/.config/yarn/global/node_modules/code-server/vendor/modules/code-oss-dev/extensions/ipynb/dist/ipynbMain.js'
Require stack:
- /usr/local/share/.config/yarn/global/node_modules/code-server/vendor/modules/code-oss-dev/out/vs/loader.js
- /usr/local/share/.config/yarn/global/node_modules/code-server/vendor/modules/code-oss-dev/out/bootstrap-amd.js
- /usr/local/share/.config/yarn/global/node_modules/code-server/vendor/modules/code-oss-dev/out/bootstrap-fork.js.

Screenshot/Video

[Notebook Creation]: image

[Notebook Opening]: image


Content of folder /usr/local/share/.config/yarn/global/node_modules/code-server/vendor/modules/code-oss-dev/extensions/ipynb (Mentioned in the above errors) image

Does this issue happen in VS Code?

Are you accessing code-server over HTTPS?

Notes

Trying to work with Jupiter Notebooks, unable to have it working with ms-python.python & ms-toolsai.jupyter extensions having tried both GUI and CLI (with code-server --install-extension) install methods. Tried to look for other issues posted, no one seems to be similar as most were related to stuff regarding old code-server versions (prior to 4.0)

Tried with enviroments:

Nginx reverse proxy is used to access code-server

jsjoeio commented 2 years ago

Oops. Looks like our new template is missing reproduction steps. How do I reproduce this?

vdallavalle commented 2 years ago

Well, i I use the docker image linuxserver/code-server exposing port 8443.

To access webpage I use nginx with the following config:

server {
  set $forward_scheme http;
  set $server         "my_ip";
  set $port           8443;

  listen 80;
listen [::]:80;

listen 443 ssl http2;
listen [::]:443 ssl http2;

  server_name my.domain;

  # Let's Encrypt SSL
  include conf.d/include/letsencrypt-acme-challenge.conf;
  include conf.d/include/ssl-ciphers.conf;
  ssl_certificate /etc/letsencrypt/live/npm-3/fullchain.pem;
  ssl_certificate_key /etc/letsencrypt/live/npm-3/privkey.pem;
# Asset Caching
  include conf.d/include/assets.conf;

  # Block Exploits
  include conf.d/include/block-exploits.conf;

  # HSTS (ngx_http_headers_module is required) (63072000 seconds = 2 years)
  add_header Strict-Transport-Security "max-age=63072000;includeSubDomains; preload" always;

    # Force SSL
    include conf.d/include/force-ssl.conf;

proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $http_connection;
proxy_http_version 1.1;

  access_log /data/logs/proxy-host-3_access.log proxy;
  error_log /data/logs/proxy-host-3_error.log warn;

access_log /data/logs/default.log proxy;
proxy_set_header X-Forwarded-Host $host;

  location / {
    set              $targetUri http://my_ip:8443;

    if ($request_uri != /){
      set            $targetUri $targetUri$request_uri;
    }

    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-Scheme $scheme;
    proxy_set_header X-Forwarded-Proto  $scheme;
    proxy_set_header X-Forwarded-For    $remote_addr;
    proxy_set_header X-Real-IP      $remote_addr;
    proxy_pass       $targetUri;

    # Asset Caching
  include conf.d/include/assets.conf;

  # Block Exploits
  include conf.d/include/block-exploits.conf;

    # Force SSL
    include conf.d/include/force-ssl.conf;

  # HSTS (ngx_http_headers_module is required) (63072000 seconds = 2 years)
  add_header Strict-Transport-Security "max-age=63072000;includeSubDomains; preload" always;

    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection $http_connection;
    proxy_http_version 1.1;

    sub_filter '</head>' '<link href="https://raw.githubusercontent.com/tonsky/FiraCode/6b13bc53d1cc79eb573b84f83b865a824f9d3f40/distr/fira_code.css" rel="stylesheet" type="text/css"></head>';
sub_filter 'font-src' 'font-src fonts.gstatic.com';
sub_filter 'style-src' 'style-src fonts.googleapis.com';
sub_filter_once on;
  }
  # Custom
  include /data/nginx/custom/server_proxy[.]conf;
}

So only weird stuff is injecting FiraCode .css file. Moreover, after first container startup I install some stuff that I need with the following:

sudo apt update
sudo apt upgrade
sudo apt install curl zsh htop build-essential python3-pip texlive ucommon-utils sagemath
pip3 install pywhat sagemath ipykernel

Besides that, there is no much more honestly. I tried to delete docker volume (container's /config folder) starting from scratch, but that makes no difference. As mentioned have tried installing both with GUI (extensions menu) and CLI with code-server --install-extension command. That's my full config, if you need more informations I am more than available. Thank you for your help :)

jsjoeio commented 2 years ago

I swear this was working when we released 4.0.1. Looks like we'll need to fix again đŸ˜ĸ

I reproduced locally with 4.0.1 using macOS + Brave.

image

Thanks for raising this issue.

benz0li commented 2 years ago

@jsjoeio Jupyter Notebooks work just fine: See https://demo.jupyter.b-data.ch for a reference deployment using JupyterHub and JupyterLab + code-server.

See https://github.com/coder/code-server/issues/4689#issuecomment-1006472915

[...] Do you access code-server in private/incognito mode? 👉 If so: Try disabling private/incognito mode or make an exception for your IP address/domain.

Service workers do not work in private/incognito mode. Accessing code-server via HTTP instead of HTTPS may cause further problems. [...]

plus

[...] one must explicitly open a folder (File > Open Folder...) before opening a Jupyter notebook.

benz0li commented 2 years ago

You may also docker run --rm -p 8888:8888 -e GEN_CERT=yes -v jupyter-user-jovyan:/home/jovyan [image] with any of the following images:

jsjoeio commented 2 years ago

[...] one must explicitly open a folder (File > Open Folder...) before opening a Jupyter notebook.

Maybe that was my issue. Thanks for following up @benz0li!

I tested on your deployment and indeed, it works as expected

image

vdallavalle commented 2 years ago

@jsjoeio Jupyter Notebooks work just fine: See https://demo.jupyter.b-data.ch for a reference deployment using JupyterHub and JupyterLab + code-server.

See #4689 (comment)

[...] Do you access code-server in private/incognito mode? 👉 If so: Try disabling private/incognito mode or make an exception for your IP address/domain. Service workers do not work in private/incognito mode. Accessing code-server via HTTP instead of HTTPS may cause further problems. [...]

plus

[...] one must explicitly open a folder (File > Open Folder...) before opening a Jupyter notebook.

Thank you for the replay but none of your suggestions has to do with my case: as you can see from my nginx configuration I am indeed using https to connect with code-server. Moreover I don't usually access application under incoginto mode (I mean, why should I :stuck_out_tongue_closed_eyes:). Actually it's not clear in the images I posted but all my tests are within an opened folder (with File > Open Folder), so that's not what causes my issue.

jsjoeio commented 2 years ago

@vdallavalle thanks for confirming! Can you share your settings.json?

vdallavalle commented 2 years ago

Here is my settings.json:

{
    /*"workbench.editor.autoLockGroups": {
        "jupiter-notebook":true
    },
    "workbench.editorAssociations": {
        "*.ipynb":"jupiter.notebook.ipynb"
    },*/
    "workbench.colorTheme": "Monokai Pro",
    "workbench.iconTheme": "Monokai Pro Icons",
    "editor.fontFamily": "Fira Code",
    "editor.fontLigatures": true, 
    "editor.fontWeight": "300",
    "editor.codeLensFontFamily": "FiraCode",
    "workbench.editor.untitled.hint": "hidden",
    "terminal.integrated.defaultProfile.linux": "zsh",
    "explorer.confirmDragAndDrop": false,
    "latex-workshop.latex.recipes": [

            { 
                "name": "pdfLatex", 
                "tools": [ 
                "pdflatex" 
                ] 
            }, 
            { 
                "name": "pdflatex -> bibtex -> pdflatex2", 
                "tools": [ 
                "pdflatex", 
                "bibtex", 
                "pdflatex", 
                "pdflatex" 
                ] 
            } 
        ], 
        "latex-workshop.latex.tools":[ 
            { 
                "name": "pdflatex", 
                "command": "pdflatex", 
                "args": [ 
                "-synctex=1", 
                "-interaction=nonstopmode", 
                "-file-line-error", 
                "-shell-escape",
                "%DOC%" 
                ], 
                "env": {} 
            }, 
            { 
                "name": "bibtex", 
                "command": "bibtex", 
                "args": [ 
                "%DOCFILE%" 
                ], 
                "env": {} 
            } 
        ],
        "workbench.editorAssociations": {
            "*.pdf": "default"
        },
        "latex-workshop.view.pdf.viewer": "tab"
}

As you can see, some jupyter settings are commented out (such settings are mentioned in other comments and somehow helped in those cases), actually the errors I'm talking about still occurs even if such settings are enabled. As I have already mentioned, I tried to delete local workspace folder and start from scratch. In such case settings.json is a blank file, however same errors happens regardless, so I don't think this settings are the cause.

benz0li commented 2 years ago

Everything working properly with codercom/code-server:4.0.1, too. One only needs

  1. apt-get update && apt-get -y install --no-install-recommends python3-venv python3-pip as root and
  2. install code-server (VS Code) extensions ms-python.python and ms-toolsai.jupyter as user [coder].

@vdallavalle How did you install code-server itself? If you install extension ms-toolsai.jupyter at system level [as root], you must take care of some stuff yourself, i.e. create its tmp-folder manually.
👉 See https://gitlab.b-data.ch/jupyterlab/r/r-ver/-/blob/master/r-ver/latest.Dockerfile#L186-L188.

crissed53 commented 2 years ago

Everything working properly with codercom/code-server:4.0.1, too. One only needs

  1. apt-get update && apt-get -y install --no-install-recommends python3-venv python3-pip as root and
  2. install code-server (VS Code) extensions ms-python.python and ms-toolsai.jupyter as user [coder].

@vdallavalle How did you install code-server itself? If you install extension ms-toolsai.jupyter at system level [as root], you must take care of some stuff yourself, i.e. create its tmp-folder manually. 👉 See https://gitlab.b-data.ch/jupyterlab/r/r-ver/-/blob/master/r-ver/latest.Dockerfile#L186-L188.

@benz0li Hi, I tried making an image with what you have suggested as follows:

FROM codercom/code-server:4.0.1

USER root
RUN apt-get update && apt-get -y install --no-install-recommends python3-venv python3-pip

USER coder
RUN code-server --install-extension ms-python.python

However, running jupyter on the image still gives the error (jupyter keeps loading). image

Do you have an idea in which part it didn't work?

benz0li commented 2 years ago

@crissed53 See https://github.com/coder/code-server/issues/4777#issuecomment-1023511535.

crissed53 commented 2 years ago

@benz0li Hi, thanks for the reply. It seems like the issue is being caused by code-server connected over HTTP instead of HTTPS. I would love to have a layer of Nginx in front of the code-server to solve this, but it seems that will be difficult as I am currently using the notebook for Kubeflow.

https://www.kubeflow.org/docs/components/notebooks/container-images/ image

They require an HTTP interface on port 8888, not HTTPS. I am not really sure if exposing the image server on the HTTPS interface is a viable option for users trying to use code-server on the top of Kubeflow.

Probably this is the reason why the default version they provide for code-server is 3.10.2 link, which does not have this kind of problem when connected with HTTP interface (I have tried this on Kubeflow, trust me). But I would really like to have code-server with a version above 4.0.0, which has features that I need such as advanced tap options and the feature that keeps terminal sessions alive even with the session reload 😭 . Do you have any suggestions?

benz0li commented 2 years ago

@crissed53 TLS termination should be done by Kubeflow not by the container image(s). Have a look at https://github.com/kubeflow/kubeflow/issues/5976.

ℹī¸ For https://demo.jupyter.b-data.ch TLS termination is done by JupyterHub. The JupyterLab container exposes HTTP on port 8888 and requests are proxied through JupyterHub.

crissed53 commented 2 years ago

@benz0li I will ask my admin if they can do the tls termination up front. I will update the progress in this issue! Thanks for your help 🙏 🙏

vdallavalle commented 2 years ago

Everything working properly with codercom/code-server:4.0.1, too. One only needs

  1. apt-get update && apt-get -y install --no-install-recommends python3-venv python3-pip as root and
  2. install code-server (VS Code) extensions ms-python.python and ms-toolsai.jupyter as user [coder].

@vdallavalle How did you install code-server itself? If you install extension ms-toolsai.jupyter at system level [as root], you must take care of some stuff yourself, i.e. create its tmp-folder manually. 👉 See https://gitlab.b-data.ch/jupyterlab/r/r-ver/-/blob/master/r-ver/latest.Dockerfile#L186-L188.

Thank you for the suggestion, actually you are right: codercom/code-server:4.0.1 works fine. At this point I wonder if the problem has something to do with the image I am running. As mentioned in another comment, I'm using the image linuxserver/code-server . You can find the corresponding Dockerfile here. It's a pretty basic setup so at this point I wonder what the problem could be since they aren't doing anything fancy. I have used their images from more than an year now and the problem came out only with version 4.0 Maybe this still has something to do with code-server itself.

btw @jsjoeio what was your setup when you reproduced the issue? Was that caused by the unopened folder or not?

benz0li commented 2 years ago

@vdallavalle I suggest you open an issue at https://github.com/linuxserver/docker-code-server/issues then.

vdallavalle commented 2 years ago

@vdallavalle I suggest you open an issue at https://github.com/linuxserver/docker-code-server/issues then.

Yeah, just tried install script on ubuntu machine (so no Docker, just plain code-server) and there is no problem whatsoever. At this point I'm pretty confident this is somehow related to linuxserver/code-server image. I'll wait for a feedback from @jsjoeio and than close this issue and open a new one in linuxserver repo. Thank for your help :blush:

jsjoeio commented 2 years ago

@vdallavalle thank you for following up! You're saving me a bunch of time 😅 I'll close this for now. If folks have issues, please refer to @benz0li's notes: https://github.com/coder/code-server/issues/4777#issuecomment-1023511535

ggydush-fn commented 2 years ago

So just to clarify, the error above is expected when running code-server locally on MacOS (as was earlier reproduced with Brave, and I just reproduced on MacOS with Chrome and code-server==4.0.2). I've tried opening a notebook after changing folder and am still faced with the following error (both with HTTP and HTTPS), installing ms-python.python and ms-toolsai.jupyter as user:

Command 'Jupyter: Create New Jupyter Notebook' resulted in an error (NO provider registered for view type: 'jupyter-notebook')
jsjoeio commented 2 years ago

@ggydush-fn strange! Any browser logs worth sharing?

ggydush-fn commented 2 years ago

Posting what I've done so far just for record keeping:

  1. Remove all config / uninstall and fresh install 4.0.2 (recommended here)
  2. Install ms-python.python and ms-toolsai.jupyter as user via Extensions tab (recommended here)
  3. Run code server locally and with --link (uses HTTPS) (HTTPS requirement mentioned here)
  4. Open notebook (both before and after opening a folder, same error) (open folder mentioned here)

Issues: Opening a notebook using command palette (Jupyter: Create New Jupyter Notebook):

Command 'Jupyter: Create New Jupyter Notebook' resulted in an error (NO provider registered for view type: 'jupyter-notebook')

Opening an .ipynb file leads to a different error:

Cannot open resource with notebook editor type 'jupyter-notebook', please check if you have the right extension installed or enabled.

Also, let me know if I missed something! I can see that 4.0.1 works on @benz0li's deployment, but struggling to get functionality that worked previously on earlier versions locally on Mac (and on Debian buster image)!

Browser logs:

Activating extension 'vscode.ipynb' failed: Cannot find module '/usr/local/Cellar/code-server/4.0.2/libexec/vendor/modules/code-oss-dev/extensions/ipynb/dist/ipynbMain.js'
Require stack:
- /usr/local/Cellar/code-server/4.0.2/libexec/vendor/modules/code-oss-dev/out/vs/loader.js
- /usr/local/Cellar/code-server/4.0.2/libexec/vendor/modules/code-oss-dev/out/bootstrap-amd.js
- /usr/local/Cellar/code-server/4.0.2/libexec/vendor/modules/code-oss-dev/out/bootstrap-fork.js.
$onExtensionActivationError @ mainThreadExtensionService.ts:95
_doInvokeHandler @ rpcProtocol.ts:472
_invokeHandler @ rpcProtocol.ts:457
_receiveRequest @ rpcProtocol.ts:373
_receiveOneMessage @ rpcProtocol.ts:295
(anonymous) @ rpcProtocol.ts:160
fire @ event.ts:577
fire @ ipc.net.ts:511
_receiveMessage @ ipc.net.ts:869
(anonymous) @ ipc.net.ts:708
fire @ event.ts:577
acceptChunk @ ipc.net.ts:284
(anonymous) @ ipc.net.ts:245
(anonymous) @ browserSocketFactory.ts:197
fire @ event.ts:577
C._fileReader.onload @ browserSocketFactory.ts:81
log.ts:319 
CRITI FAILED to destory notebook Error: NO provider registered for view type: 'jupyter-notebook'
    at O.withNotebookDataProvider (notebookServiceImpl.ts:611:10)
    at async u.createReferencedObject (notebookEditorModelResolverServiceImpl.ts:64:16)
    at async a.resolve (notebookEditorModelResolverServiceImpl.ts:216:18)
    at async l.$tryCreateNotebook (mainThreadNotebookDocuments.ts:131:15)
jsjoeio commented 2 years ago

Run code server locally and with --link (uses HTTPS) (HTTPS requirement mentioned https://github.com/coder/code-server/issues/4777#issuecomment-1023511535)

Ah, --link is deprecated fyi. If you're running locally on a Mac, HTTP via localhost works just fine (or should at least).

gogobd commented 2 years ago

I updated to 4.0.2 and now Jupyter Notebooks seem to be working fine...

jsjoeio commented 2 years ago

@gogobd great to hear! Thanks for reporting.

aghasemi commented 2 years ago

Hi,

I am having a similar issue, on version 4.0.1, and my error when trying to create a new Notebook is

Command 'Jupyter: Create New Blank Notebook' resulted in an error (command 'jupyter.createnewnotebook' not found)

The extension and the apt packages mentioned in this thread are all installed. Still no success. Any idea?

Many thanks

jsjoeio commented 2 years ago

@aghasemi can you try using 4.1.0?

aghasemi commented 2 years ago

@aghasemi can you try using 4.1.0?

I'm on 4.1.0

jsjoeio commented 2 years ago

@aghasemi can you try using 4.1.0?

I'm on 4.1.0

Ah, you said 4.0.1 in the previous message:

I am having a similar issue, on version 4.0.1, and my error when trying to create a new Notebook is

Can you see if you're facing the same issue as https://github.com/coder/code-server/issues/4976 or https://github.com/coder/code-server/issues/4964?

aghasemi commented 2 years ago

@aghasemi can you try using 4.1.0?

I'm on 4.1.0

Ah, you said 4.0.1 in the previous message:

I am having a similar issue, on version 4.0.1, and my error when trying to create a new Notebook is

Can you see if you're facing the same issue as #4976 or #4964?

I can confirm it is 4.1.0. Sorry for the typo.

It is likely #4976, as I am also running CS via nginx on a domain.

jsjoeio commented 2 years ago

It is likely https://github.com/coder/code-server/issues/4976, as I am also running CS via nginx on a domain.

Awesome! Thanks for checking. Feel free to 👍đŸŧ that issue and subscribe there so you know when it's fixed