oraios/serena · error · RuntimeError

R is not installed or not in PATH

Error message

R is not installed or not in PATH

What it means

This library's R language server wrapper runs `_check_r_installation()` in `__init__` and invokes `R --version` via subprocess. If R exists but returns a non-zero exit code (or is a broken shim), the wrapper raises this RuntimeError because the language server binary can never be started without a working R interpreter.

Source

Thrown at src/solidlsp/language_servers/r_language_server.py:39

    @override
    def is_ignored_dirname(self, dirname: str) -> bool:
        # For R projects, ignore common directories
        return super().is_ignored_dirname(dirname) or dirname in [
            "renv",  # R environment management
            "packrat",  # Legacy R package management
            ".Rproj.user",  # RStudio project files
            "vignettes",  # Package vignettes (often large)
        ]

    @staticmethod
    def _check_r_installation() -> None:
        """Check if R and languageserver are available."""
        try:
            # Check R installation
            result = subprocess_run(["R", "--version"], capture_output=True, text=True, check=False)
            if result.returncode != 0:
                raise RuntimeError("R is not installed or not in PATH")

            # Check languageserver package
            result = subprocess_run(
                ["R", "--vanilla", "--quiet", "--slave", "-e", "if (!require('languageserver', quietly=TRUE)) quit(status=1)"],
                capture_output=True,
                text=True,
                check=False,
            )

            if result.returncode != 0:
                raise RuntimeError(
                    "R languageserver package is not installed.\nInstall it with: R -e \"install.packages('languageserver')\""
                )

        except FileNotFoundError:
            raise RuntimeError("R is not installed. Please install R from https://www.r-project.org/")

    def __init__(self, config: LanguageServerConfig, repository_root_path: str, solidlsp_settings: SolidLSPSettings):

View on GitHub (pinned to 7fcbca7e62)

Solutions

  1. Install R (e.g. `apt install r-base`, `brew install r`, or from https://www.r-project.org/) so `R --version` succeeds
  2. Verify `which R` points at the real interpreter and run `R --version` manually; fix/remove broken symlinks or shims
  3. Activate the correct environment (conda/mise) or prepend R's bin directory to PATH before launching the app

Example fix

# before (broken shim in PATH)
$ R --version  # exit code 1, symlink to deleted R 4.1

# after
$ ln -s /usr/local/bin/R-4.3 /usr/local/bin/R   # or reinstall R
$ R --version  # R version 4.3.1 -- exit 0
Defensive patterns

Strategy: validation

Validate before calling

import shutil, subprocess
if shutil.which("R") is None:
    raise SystemExit("R is not on PATH; install R first")
probe = subprocess.run(["R", "--version"], capture_output=True, text=True)
if probe.returncode != 0:
    raise SystemExit(f"R exists but fails to run: {probe.stderr}")

Type guard

def has_working_r() -> bool:
    try:
        return subprocess.run(["R", "--version"], capture_output=True, check=False).returncode == 0
    except FileNotFoundError:
        return False

Try / catch

try:
    server = RLanguageServer(config, repo_root, settings)
except RuntimeError as e:
    if "not installed or not in PATH" in str(e):
        logger.error("Install R and ensure it is on PATH: %s", e)
        raise SystemExit(1) from e
    raise

Prevention

When it happens

Trigger: Instantiating the R language server (via `__init__` -> `_check_r_installation`) when `R --version` exits non-zero: e.g. `R` resolves to a stub/alias script that fails, a broken Homebrew/conda link, or R installed but crashing on startup.

Common situations: R was uninstalled or upgraded and PATH still points at a dead symlink; a conda/miniconda environment without R is active; a Windows 'R.exe' shim exists but its target is missing; PATH ordering picks an incompatible R build.

Related errors


AI-assisted analysis of oraios/serena@7fcbca7e62 (2026-08-29). Data as JSON: /api/errors/37809878d103c6da. Report an issue: GitHub.