0

I have been trying to learn how to use my R scripts in a bash like Git, so I can run said script in a pipeline, but I am having trouble getting started. I am using a Windows 10 system, and using the Git Bash as my mock Unix bash.

Here is the link to the tutorial I am trying to learn off of: http://swcarpentry.github.io/r-novice-inflammation/05-cmdline/index.html

As a super simple example of a script, I made a script called session-info.R in RStudio. The only code it contained was:

sessionInfo()

I then went to Git Bash, and making sure that I was in the same directory as the script that I just wrote, I typed this into the command line:

Rscript session-info.R

To which I got the error: "bash: Rscript: command not found" Does anyone have any ideas to how I could fix this? I feel like this is a really beginner error, but I haven't been able to figure out for a little while. Thank you for your assistance.

  • That is whatever console you're using not having Rscript on the path. So it's not really an issue with R and just an issue with you getting the system set up properly. – Dason Jun 29 '21 at 00:14
  • I set up R on my computer as the Software Carpentry lesson told me to do, so yeah it probably isn't an R thing. Do you know of some ways to maybe switch my windows operating system to a linux, or some other os that wouldn't prevent me from using Rstudio with Unix? Getting my system set up properly is a pretty broad solution... – powerline Jun 29 '21 at 00:47
  • Here's how you can set your PATH environment variable using git bash: https://stackoverflow.com/questions/45980107/extend-path-variable-in-git-bash-under-windows. When you call a program from the command line, Windows will only look in the places specified in your PATH variable. If you run `paste0(normalizePath(R.home("bin")))` in R, that should return the path you need to add to your PATH environment variable. – MrFlick Jun 29 '21 at 01:06
  • @MrFlick I think that worked, since sessionInfo() is now displaying! Thanks much! – powerline Jun 29 '21 at 17:48
  • Actually, I seem to have run into a new error. After pasting the command: paste0(normalizePath(R.home("bin"))) into R, I got the path that I needed to add. I then used the export PATH=$PATH "", with the path that I got from R in the quotations. Once I did this, I moved to the directory where session-info.R was in Git Bash, then I ran the script using the command in the original post. It displayed the desired information, but with the warning message: "During startup - Warning message: Setting LC_CTYPE=en_US.UTF-8 failed" as well. When I tried to run a similar script, I got the same error.. – powerline Jun 29 '21 at 17:57

0 Answers0