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

Address languageserver and jsonlite VS Code R extension errors #26

Open
MiguelRodo opened this issue Jul 15, 2024 · 1 comment
Open

Comments

@MiguelRodo
Copy link
Owner

MiguelRodo commented Jul 15, 2024

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.

@MiguelRodo MiguelRodo pinned this issue Jul 15, 2024
@MiguelRodo
Copy link
Owner Author

Upon starting the container, we could run Rscript --vanilla -e '<cmd>; install.packages(c("jsonlite", "languageserver"))' where <cmd> is the following (with semi-colons in between):

# 1. get home directory
#2. get .cache/R/ren/library subdirectory
# 3. List whatever directories are in there, and `cd` into the one that was created last
# 4.Cd into whatever directory was created last
# 5. CD into the directory whose <major>.<minor> version matches current
# 6. CD into whatever directory was created last
/home/rstudio/.cache/R/renv/library/Prac23StatsSeecCourseSimpleReg-ebd2789b/linux-ubuntu-jammy/R-4.4/x86_64-pc-linux-gnu

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

No branches or pull requests

1 participant