First, you need to understand the difference between a terminal (the app in which you can type commands and read outputs), the shell (which interprets the commands), and the programs that are called by the commands (which on Unix systems usually includes ls
, mkdir
etc). Every operating system comes with some combination of these.
Windows traditionally comes with Windows Console, a pretty bad terminal app, and more recently has Windows Terminal available (back in 2019 I had to explicitly install Windows Terminal from the app store, nowadays I think it come pre-installed, need to confirm). In addition, RStudio does have a Terminal pane.
Inside a terminal window, one can then run a shell. On Windows, traditionally the shell is cmd.exe
, and more recently (not very recent though) Powershell. But if other shells are available, one can run those instead. For example, if you install WSL (which creates a Linux system running on the same computer that can interact with Windows files and programs), you can run the Linux shell in Windows Terminal. If you install Git, you will get the suggestion to install Git Bash alongside; you can then run Git Bash from a terminal.
Sure enough, Rtools also comes with a bash shell executable. It is usually somewhere like C:\rtools44\usr\bin\bash.exe
. So that means you can go to RStudio terminal options, and set a "Custom" shell giving this path (or similarly on Windows Terminal).
Now the question is: is this a good idea? I'm not fully convinced on this. For a quick and dirty "I need bash and don't already have it installed" scenario, I don't really see what could go wrong. It should just work. But in a course for unexperienced future data scientists, it fells like they should rather take good habits. If they're going to work with data a lot, I would recommend installing a full Linux distribution with WSL and Windows Terminal, it doesn't take much storage space and it's making the proper tools available for the long term (with the possibility of installing Linux packages etc). If they're going to install Git anyway, the Git Bash that comes with it is not as convenient as a full WSL, but at least it's standard and "clean".
Rtools seems to me less future-proof, since it gets reinstalled in different locations when updating R versions etc. Also the main point of Rtools is to make the compilers available, bash is more a "side-effect", maybe one day the Rtools maintainer will decide to ship a different shell.