Rstudio server path isn't picking up linuxbrew dependencies?

Background

I am running a local instance of Rstudio server on WSL2

Problem

I cannot use blogdown::build_site(). I get the following error message Error: failed to download modules: exec: "go": executable file not found in $PATH

I downloaded go via linux brew. So I suspect a path issue.

Investigation

In the RStudio server R console, I ran system("echo $PATH") and I get the following:

/sbin:/usr/sbin:/bin:/usr/bin:/usr/lib/rstudio-server/bin/postback:/usr/lib/rstudio-server/bin/postback:/usr/lib/rstudio-server/bin/postback:/usr/lib/rstudio-server/bin/postback

However, when I am in the RStudio linux terminal, go into R, and then run system("echo $PATH"), I get a much different result:

/home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin:/sbin:/usr/sbin:/bin:/usr/bin:/usr/lib/rstudio-server/bin/postback:/usr/lib/rstudio-server/bin/postback:/usr/lib/rstudio-server/bin/postback:/bin:/snap/bin

Question

How can I get the R console in RStudio server to pick the dependencies obtained via linuxbrew?

Solution

I figured out the solution: Sys.setenv(PATH = paste0("/home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin:", old_path)). Where old_path <- Sys.getenv("PATH")

Reference

I got inspiration from this link

Caveat

If there is a better way, please let me know, but this works :slight_smile:

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.