Rscript works in R (terminal) but not in RStudio

Here is the script: afni/AFNIio.R at master · afni/afni · GitHub

I could source it in R (terminal), and functions in this script worked well; but it did not work in RStudio, both on Mac and Ubuntu. This problem seemed related to different environment path between terminal and RStudio.


I recently had a frustrating problem where the reverse was true. To troubleshoot you could do a


in each environment immediately after opening a fresh session & compare. I ended up saving the working environment into a file after adding = between each pair, reading it into a fresh session in the failing environment with a readRenviron('dotenvFile'), confirming that the code now worked, then commenting out chunks of the dotenv file & repeating the exercise until I worked out which environment variable(s) were at fault.

Once you've worked out the culprits you could make sure they're set (or unset) appropriately as here:

Hope that gives you a way into the problem.

1 Like

This topic was automatically closed 21 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.