Resources for beginner students about RTools and the Terminal?

I teach a free data science course for beginners. A big part of the course is learning about the Terminal. How do you get things done from the command line?

My problem is working with students who use Windows (which I do not). I have them install RTools. I think that, magically, this should make the Terminal a Unix-like shell, rather than its default Powershell. But, for many students, this does not seem to work.

I need to understand what is happening at a deeper level. I need to figure out the ways that this can fail for students, how to debug it, and how to fix it.

Any pointers?

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.

Thanks for providing all this useful information!

Key clarification is that I am using Positron. Sorry for not making that clear! So, I am looking for info about the Terminal in Positron on Windows machines.

So that means you can go to RStudio terminal options, and set a "Custom" shell giving this path (or similarly on Windows Terminal).

Is there a recommended way to do this automatically behind the scenes? For example, I have students run a function, tutorial.helpers::set_positron_settings() which modifies files like .Rprofile and settings.json. My goal is to just make a Unix-like shell appear as the default for students using Windows.

Now the question is: is this a good idea? I'm not fully convinced on this

Reasonable people can differ! But, in my class, I want to teach students lots of command line stuff, and ensuring that everyone is using a Unix-like shell seems best. WSL seems like overkill, but I will try to learn more.

Rtools seems to me less future-proof

This seems like good advice! Thanks. So, having investigated this more, I am now having Windows students do two things:

First, install Git for Windows.

Second, run a script which modifies their settings.json file to include:

"terminal.integrated.defaultProfile.windows": "Git Bash"

Does that seem a sensible approach?

Sorry, I never used Positron, so can't give specific instructions. My understanding is that Positron is a fork of VSCode, which provides its own terminal and allows you to select a shell; so it should be possible to configure a custom shell. Probably by creating a terminal profile with path to the MSYS2 installation from Rtools (or a Git Bash installation).

One thing you'll need to be careful about is that the installation path of Rtools depends on the R version, e.g. rtools-44 for R 4.4, so if different students potentially have different versions of R installed, the path needs to be customized (and if some students may have older Rtools, they might have only the mingw64 bash and not the MSYS2, again a need to customize the path). This is one of the reasons the Rtools approach may be less straightforward.

Without direct personal experience, this does seem like a sensible approach, one that is listed in the official documentation (making sure that "Git Bash" has a prewritten entry in settings.json).