Terminal and R won't work together

I have installed a python program using the Terminal Tab. I then added the path to the installed library to the environment PATH; and checked that I can find the installed program

python3 -m pip install --user --upgrade cutadapt
which cutadapt

And that works. The problem is when I try to use that program through an R script

system2("which", args = "cutadapt")

then it can't find it.

Any best practices out there to use unix installed programs with Rstudio cloud?

Can you check which shell the Rstudio cloud is using? Make sure you use the same one as Rstudio.


system2("echo", "$SHELL")

Thanks for the reply - The result is interesting: running echo $SHELL from the Terminal Tab (within Rstudio cloud) returns /bin/bash;
system2("echo", "$SHELL") returns nothing

Do you have a .zshrc or any type of rc file that contains a path export?

Can you run any commands through system2?

Say system2("whoami")

Hi there,

  • In some of my Rstudiocloud projects I have a .bash_profile with a PATH variable, but not in other projects. It does not seem to make a difference on whether system2 returns the same paths that directly looking at the terminal.
  • I just run system2("whoami") and it returned

I looked at the environment vars in both cases - I used
printenv from the terminal tab in Rstudiocloud.
I made them into a df and these are the entries that are different between the two

We have clearly found the problem, the two environments are completely different, now we just need to resolve it.

Can you run

system2("export", ".bash_profile")

Where in the profile you have the path for the binary cutadapt?

Cool! The path sits in a .bash_profile file I created in the project root (/cloud/project/.bash_profile), but system2("export", ".bash_profile") does not work.

Sorry, I mean place the following statement

export PATH="path to cutadapt your-dir:$PATH"
at the last line of your .bash_profile and run system2("source", "path_to_bash_profile/.bash_profile")

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