rwindowscommand-linegit-bash

Trying to run Rscript from command line: Rscript command not found


I am new to learning R and working in command line. I am attempting to run an R script from command line, however I am getting an error line.

bash: Rscript: command not found

I have searched for a couple hours, tried uninstalling & re-installing R, tried adding Rscript.exe to Path in 'system environment variables'...

When I run echo $PATH I can confirm that the path is listed: C:/Program Files/R/R-4.3.0/bin/Rscript.exe

I am working from the same directory as the R script I am attempting to run.

For reference, I am running Windows 11, R 4.3.0, and using Git Bash.

I have found some similar questions on here, but none of the answers are working for me. I also am at a low level of knowledge on this topic and struggling to follow some suggestions.

Anyhow, if anyone is able to help me out I would super appreciate it! Happy to answer any questions with more details, I just don't know what I need to include.


Solution

  • Your $PATH variable should contain the directory, not the executable. Assuming the command is at C:/Program Files/R/R-4.3.0/bin/Rscript.exe, then echo $PATH needs to show C:/Program Files/R/R-4.3.0/bin.