Rstan or C++ Toolchain Error

Operating System: Windows
Interface Version: 2.19.2
Compiler/Toolkit: ???

I’m trying to install RStan, so that I can use the ‘rethinking’ package that comes with the textbook ‘Statistical Rethinking’. I’m following the instructions from this website:https://github.com/stan-dev/rstan/wiki/RStan-Getting-Started
When I get to ‘Checking the C++ Toolchain’ and use this code: ‘pkgbuild::has_build_tools(debug = TRUE)’,
I get an error in R that says:
‘Error in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]) :
there is no package called ‘fansi’’

I am a novice and know very little about RStudio. Any help is much appreciated.

You should first do

install.packages("fansi")

but I don’t know why.

Thank you! That worked for me.