Skip to content
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

Deno Jupyter Kernel install not respecting new Jupyter v5 platform directories #27984

Open
benjamincburns opened this issue Feb 5, 2025 · 2 comments
Labels
deno jupyter Related to "deno jupyter" subcommand

Comments

@benjamincburns
Copy link

benjamincburns commented Feb 5, 2025

Version: Deno 2.1.9

Problem

Deno is currently installing its Jupyter kernel config to a deprecated installation location on macOS (and probably other platforms). It should be checking the JUPYTER_PLATFORM_DIRS environment variable, and installing to the updated location when it is set to a truthy value.

Background

In version 5 of jupyter_core, Jupyter has moved to a platform-specific directory structure and has deprecated the old one. If you use jupyter libraries that depend on jupyter_core (e.g. jupyter_client, in my case), it'll spit out a deprecation warning unless you set JUPYTER_PLATFORM_DIRS=1 in your environment.

When you set JUPYTER_PLATFORM_DIRS=1, it switches over to use the new directory structure. If kernel configs aren't installed in those locations, jupyter_core can't find them.

How to reproduce

In the example below (running on macOS), you can see that I've mirrored my existing kernel installs over to the new directory structure:

(bburns@ben) 2025-02-06T12:10:22+1300 😁 ~/projects
λ jupyter kernelspec list
Available kernels:
  sos        /Users/bburns/Library/Jupyter/kernels/sos
  python3    /Users/bburns/.pyenv/versions/3.11.11/share/jupyter/kernels/python3


(bburns@ben) 2025-02-06T12:10:30+1300 😁 ~/projects
λ JUPYTER_PLATFORM_DIRS=1 jupyter kernelspec list
Available kernels:
  sos        /Users/bburns/.local/share/jupyter/kernels/sos
  python3    /Users/bburns/.pyenv/versions/3.11.11/share/jupyter/kernels/python3

When I install deno's kernel with the JUPYTER_PLATFORM_DIRS env var set, jupyter can't find it.

(bburns@ben) 2025-02-06T12:10:37+1300 😁 ~/projects
λ JUPYTER_PLATFORM_DIRS=1 deno jupyter --install
Warning "deno jupyter" is unstable and might change in the future.
✅ Deno kernelspec installed successfully.


(bburns@ben) 2025-02-06T12:10:53+1300 😁 ~/projects
λ JUPYTER_PLATFORM_DIRS=1 jupyter kernelspec list
Available kernels:
  sos        /Users/bburns/.local/share/jupyter/kernels/sos
  python3    /Users/bburns/.pyenv/versions/3.11.11/share/jupyter/kernels/python3

However, if I drop back to the deprecated directory structure, it finds it in the old, deprecated location

(bburns@ben) 2025-02-06T12:10:58+1300 😁 ~/projects
λ jupyter kernelspec list
Available kernels:
  deno       /Users/bburns/Library/Jupyter/kernels/deno
  sos        /Users/bburns/Library/Jupyter/kernels/sos
  python3    /Users/bburns/.pyenv/versions/3.11.11/share/jupyter/kernels/python3

How to fix

When the JUPYTER_PLATFORM_DIRS env var is set on macOS, deno kernel install should install to $HOME/Library/Application Support/Jupyter/kernels rather than $HOME/Library/Jupyter/kernels.

I believe the install target for other platforms has changed as well, but I'm not sure what the most universal target should be for those.

@marvinhagemeister
Copy link
Contributor

For anyone looking into this. The kernel installation code for Deno is here

pub fn install() -> Result<(), AnyError> {
let user_data_dir = user_data_dir()?;
let kernel_dir = user_data_dir.join("kernels").join("deno");
std::fs::create_dir_all(&kernel_dir)?;
let kernel_json_path = kernel_dir.join("kernel.json");

@marvinhagemeister marvinhagemeister added the deno jupyter Related to "deno jupyter" subcommand label Feb 6, 2025
@benjamincburns
Copy link
Author

If it's helpful at all, this is how I'm working around this issue in markdown-exec: https://github.com/pawamoy/markdown-exec/pull/70/files#diff-b803fcb7f17ed9235f1e5cb1fcd2f5d3b2838429d4368ae4c57ce4436577f03fR56-R104

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
deno jupyter Related to "deno jupyter" subcommand
Projects
None yet
Development

No branches or pull requests

2 participants