rustjupytercondarustup

Cannot connect to rust kernel from a jupyter server in a conda env


I have been trying to install a Rust kernel for a Jupyter server inside a dedicated conda environment but I get errors.

Slighty adjusting steps from:
https://depth-first.com/articles/2020/09/21/interactive-rust-in-a-repl-and-jupyter-notebook-with-evcxr/

  1. conda create -n rusttest
  2. conda activate rusttest
  3. conda install -c conda-forge rust jupyterlab
  4. conda install -c anaconda cmake -y
  5. cargo install evcxr_jupyter
  6. Add $HOME/.cargo/bin to my PATH variable (export PATH)
  7. evcxr_jupyter --install (here I already see the kernel is installed outside the env)
  8. jupyter lab

The kernel is visible on the dashboard however when I try to start a notebook with it the connection fails and I get:

Error: Failed to find sysroot for Cargo.toml file /tmp/.tmpbZ0Pkw/Cargo.toml. Is rust-src installed?

I have tried manually:

jupyter kernelspec install {MY_PATH_DURING_PKG_INSTALLATION}/Jupyter/kernels/rust --sys-prefix

And I get:

[InstallKernelSpec] Installed kernelspec rust in {MY_PATH}/miniconda3/envs/rusttest/share/jupyter/kernels/rust

Which seems OK (inside the correct conda env) but the error persists.

Is there any way to add a working kernel just to this one jupyter server inside that env?
(I want Rust to be gone when I start jupyter lab from another conda env)

EDIT

After digging into this I think the first thing is to get rust-src installed inside that conda environment... I don't know how...


Solution

  • Solved:

    I needed to download https://static.rust-lang.org/dist/2022-05-19/rust-src-1.61.0.tar.gz manually and extract it under the env dir such that XXX/miniconda3/envs/rusttest/lib/rustlib/src/rust exists.