Stéphane Laurent
Stéphane Laurent

Reputation: 84529

`Sys.which` does not find an executable file in RStudio

I'm using Ubuntu 18.04, R 3.6.3, and a recent version of RStudio. I have an executable named brittany. When I run which brittany in a terminal, it is found. When I run R in a terminal and I type Sys.which("brittany"), it is found. But when I type Sys.which("brittany") in the RStudio console, it is not found. Why? The path of this file is /home/stla/.local/bin/brittany.

I've found a workaround: if I do a symbolic link to this file in a folder that does not contain a period in its path, the symbolic link is found and I can execute it. Looks like a RStudio bug.

Upvotes: 0

Views: 525

Answers (1)

Dirk is no longer here
Dirk is no longer here

Reputation: 368261

So the $PATH value for your shell is different (at start, or via your 'dot'-files) than it is for RStudio. And the result path reveals: /home/$USER/.local/bin is a private path, not a system path.

I think RStudio honors ~/bin so maybe create that and add a softlink.

On the other hand, on my machine (Ubuntu 20.04, R 4.0.2, RStudio 1.4.781) I see

R> system("echo $PATH")
/home/edd/.local/bin:/home/edd/bin:/usr/local/sbin:/usr/local/bin:\
/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:\
/usr/lib/rstudio/bin/postback
R>

and this is not a fluke of system() as Sys.getenv("PATH") shows the same.

Upvotes: 1

Related Questions