I believe this might be due to some makeflags missing when working with RTools42, can you try running this:
cpp_options <- list(
"CXXFLAGS += -Wno-nonnull",
"TBB_CXXFLAGS= -U__MSVCRT_VERSION__ -D__MSVCRT_VERSION__=0x0E00"
)
cmdstanr::cmdstan_make_local(cpp_options = cpp_options)
cmdstanr::rebuild_cmdstan()