Skip to content

Address languageserver and jsonlite VS Code R extension errors #26

@MiguelRodo

Description

@MiguelRodo

Libraries

Here are paths under various settings:

# vs code extension paths
R library paths:
"/home/rstudio/.cache/R/renv/library/Prac23StatsSeecCourseSimpleReg-ebd2789b/linux-ubuntu-jammy/R-4.4/x86_64-pc-linux-gnu"
"/home/rstudio/.cache/R/renv/sandbox/linux-ubuntu-jammy/R-4.4/x86_64-pc-linux-gnu/25ebdc09"
Error in loadNamespace("jsonlite") : 
  there is no package calledjsonliteCalls: loadNamespace -> withRestarts -> withOneRestart -> doWithOneRestart
Execution halted

# renv paths
"/workspaces/.local/.cache/R/renv/linux-ubuntu-jammy/R-4.4/x86_64-pc-linux-gnu"
"/home/rstudio/.cache/R/renv/sandbox/linux-ubuntu-jammy/R-4.4/x86_64-pc-linux-gnu/25ebdc09"

# renv paths (with sandbox disabled)
"/workspaces/.local/.cache/R/renv/linux-ubuntu-jammy/R-4.4/x86_64-pc-linux-gnu"
"/usr/local/lib/R/library"

# non-renv paths:
"/workspaces/.local/lib/R"
"/usr/local/lib/R/site-library"
"/usr/local/lib/R/library"  

what worked (with sandbox enabled)

  1. In workspace directory, run radian --vanilla
  2. Run the following:
lib_path <- "/home/rstudio/.cache/R/renv/sandbox/linux-ubuntu-jammy/R-4.4/x86_64-pc-linux-gnu/25ebdc09"
install.packages(
  c("jsonlite", "languageserver"),
  lib = lib_path,
  repos = "https://cloud.r-project.org"
)

No matter how I start R, by default I install into libraries not used by the VS Code extension.

The workaround in future is just to start R in vanilla mode, and install languageserver and jsonlite, explicitly installing into the paths indicated by the VS Code R extension.

To use the above code then, just replace the value of lib_paths with the relevant value.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions