{"record":{"id":"37809878d103c6da","repo":"oraios/serena","slug":"r-is-not-installed-or-not-in-path","errorCode":null,"errorMessage":"R is not installed or not in PATH","messagePattern":"R is not installed or not in PATH","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"src/solidlsp/language_servers/r_language_server.py","lineNumber":39,"sourceCode":"\n    @override\n    def is_ignored_dirname(self, dirname: str) -> bool:\n        # For R projects, ignore common directories\n        return super().is_ignored_dirname(dirname) or dirname in [\n            \"renv\",  # R environment management\n            \"packrat\",  # Legacy R package management\n            \".Rproj.user\",  # RStudio project files\n            \"vignettes\",  # Package vignettes (often large)\n        ]\n\n    @staticmethod\n    def _check_r_installation() -> None:\n        \"\"\"Check if R and languageserver are available.\"\"\"\n        try:\n            # Check R installation\n            result = subprocess_run([\"R\", \"--version\"], capture_output=True, text=True, check=False)\n            if result.returncode != 0:\n                raise RuntimeError(\"R is not installed or not in PATH\")\n\n            # Check languageserver package\n            result = subprocess_run(\n                [\"R\", \"--vanilla\", \"--quiet\", \"--slave\", \"-e\", \"if (!require('languageserver', quietly=TRUE)) quit(status=1)\"],\n                capture_output=True,\n                text=True,\n                check=False,\n            )\n\n            if result.returncode != 0:\n                raise RuntimeError(\n                    \"R languageserver package is not installed.\\nInstall it with: R -e \\\"install.packages('languageserver')\\\"\"\n                )\n\n        except FileNotFoundError:\n            raise RuntimeError(\"R is not installed. Please install R from https://www.r-project.org/\")\n\n    def __init__(self, config: LanguageServerConfig, repository_root_path: str, solidlsp_settings: SolidLSPSettings):","sourceCodeStart":21,"sourceCodeEnd":57,"githubUrl":"https://github.com/oraios/serena/blob/7fcbca7e62555ec2287ddb2f083caee805848ea6/src/solidlsp/language_servers/r_language_server.py#L21-L57","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Install R (e.g. `apt install r-base`, `brew install r`, or from https://www.r-project.org/) so `R --version` succeeds","Verify `which R` points at the real interpreter and run `R --version` manually; fix/remove broken symlinks or shims","Activate the correct environment (conda/mise) or prepend R's bin directory to PATH before launching the app"],"exampleFix":"# before (broken shim in PATH)\n$ R --version  # exit code 1, symlink to deleted R 4.1\n\n# after\n$ ln -s /usr/local/bin/R-4.3 /usr/local/bin/R   # or reinstall R\n$ R --version  # R version 4.3.1 -- exit 0","handlingStrategy":"validation","validationCode":"import shutil, subprocess\nif shutil.which(\"R\") is None:\n    raise SystemExit(\"R is not on PATH; install R first\")\nprobe = subprocess.run([\"R\", \"--version\"], capture_output=True, text=True)\nif probe.returncode != 0:\n    raise SystemExit(f\"R exists but fails to run: {probe.stderr}\")","typeGuard":"def has_working_r() -> bool:\n    try:\n        return subprocess.run([\"R\", \"--version\"], capture_output=True, check=False).returncode == 0\n    except FileNotFoundError:\n        return False","tryCatchPattern":"try:\n    server = RLanguageServer(config, repo_root, settings)\nexcept RuntimeError as e:\n    if \"not installed or not in PATH\" in str(e):\n        logger.error(\"Install R and ensure it is on PATH: %s\", e)\n        raise SystemExit(1) from e\n    raise","preventionTips":["Pin R in dev/CI images (e.g. install r-base in the Dockerfile) so it's always present","Run `R --version` in a preflight/startup health check before constructing language servers","Avoid R version-manager shims in daemon/server environments; use absolute interpreter paths"],"tags":["r","environment","path","runtime"],"backgroundTag":"dependency-not-found","analyzedSha":"7fcbca7e62555ec2287ddb2f083caee805848ea6","analyzedAt":"2026-08-29T00:04:09.619Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}