Error in sink(type = "output") : invalid connection Error 126

Hello
I am new at this. I think my set up is wrong and that I have Makevars element pointed at the C++ compiler in setup. This is the error I am getting:

Error in compileCode(f, code, language = language, verbose = verbose) :
using C++ compiler: 'G__~1.EXE (GCC) 12.2.0’using C++14/bin/sh: line 1: C:\rtools43\x86_64-w64-mingw32.static.posix\bin: Is a directorymake: *** [C:/PROGRA~1/R/R-43~1.1/etc/x64/Makeconf:273: file199c38f52aeb.o] Error 126
Error in sink(type = “output”) : invalid connection

Is that right? Rstan is also not appearing in my library. I feel that I have done something very wrong here. I appreciate any advice and of you could provide to a newbie. Many thanks. Happy to post any info required to get to the bottom of this. My previous install was on a windows 10 machine with R4.2.2 where this is a windows 11 machine with R4.3.1.