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

Detection of servers installed in kernel (but not server) environment #923

Closed
jrouly opened this issue Apr 3, 2023 · 3 comments
Closed
Labels
enhancement New feature or request

Comments

@jrouly
Copy link

jrouly commented Apr 3, 2023

I'm not 100% sure if this is the correct repository to file this issue so please forgive me in advance if I've bungled this.

What I am trying to do...

I'm trying to run JupyterHub with an R kernel, using Conda (micromamba) to manage environments, with an R language server.

The steps I've followed are essentially:

  1. Install jupyterlab, jupyterhub into the jupyter environment
  2. Install R, r-irkernel, r-languageserver into the R environment
  3. Activate the R environment and invoke IRkernel::installspec(user = FALSE, prefix = '$JUPYTER_HOME')

This works great and sets up an R kernel. However, despite having installed r-languageserver (which I can confirm by running library(languageserver) in a notebook), JupyterLab is unable to detect the R language server. It complains:

No language server for r detected

and recommends I troubleshoot finding Rscript on the PATH. It is on the PATH (in the R environment), and JupyterLab is clearly aware of this since it's able to run notebooks on the R kernel just fine. And yet, it cannot find the language server.

How I would like to learn how to do it...

I think the instructions in the documentation are pretty clear as-is, this was a very unexpected case. Having a section of documentation specifically for cross-environment kernels would potentially be helpful.

How the project might keep the docs accurate...

Having an additional section to the installation documentation to help with cross-account server scenarios could probably address this.

@krassowski
Copy link
Member

It is on the PATH (in the R environment), and JupyterLab is clearly aware of this since it's able to run notebooks on the R kernel just fine

These are two different paths, so knowing that one works does not help with the other really.

  1. Install jupyterlab, jupyterhub into the jupyter environment
  2. Install R, r-irkernel, r-languageserver into the R environment

Currently detection of R language sever comes down to what Rscript -e cat(system.file(package='languageserver')) returns in the environment where jupyter-server gets spawned (in your case jupyter).

class RLanguageServer(ShellSpec):
package = "languageserver"
key = "r-languageserver"
cmd = "Rscript"
@property
def args(self):
return ["--slave", "-e", f"{self.package}::run()"]
@property
def is_installed_args(self):
return ["-e", f"cat(system.file(package='{self.package}'))"]

When you install kernelspec It would technically be possible to use path from kernel spec it creates a JSON file like this:

{
  "argv": ["/a/path/to/your/R", "--slave", "-e", "IRkernel::main()", "--args", "{connection_file}"],
  "display_name": "R",
  "language": "R"
}

While we could potentially check for kernelspecs contents it is not currently implemented. We would need to extract /a/path/to/your/R bit and use it instead of Rscript. One would need to find a clean way to obtain it for currently running kernel (as you could have multiple different versions of IRKernel installed).

@krassowski krassowski changed the title Confused about cross-environment LSP installation Detection of servers installed in kernel (but not server) environment May 28, 2023
@krassowski
Copy link
Member

Maybe of more use for now, you can create custom serverspecs pointing to any executable you would like, see https://jupyterlab-lsp.readthedocs.io/en/latest/Configuring.html#

@krassowski krassowski added the enhancement New feature or request label May 28, 2023
@krassowski
Copy link
Member

Let's consolidate the discussion in #533 which was opened earlier and has more replies.

While we could potentially check for kernelspecs contents it is not currently implemented. We would need to extract /a/path/to/your/R bit and use it instead of Rscript. One would need to find a clean way to obtain it for currently running kernel (as you could have multiple different versions of IRKernel installed).

A concrete idea for instead modifying the kernelspecs was proposed in #533 (comment).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants