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

I installed rstan 2.21.8 and r 4.2.2

when I run the 8 schools model I get

Error in compileCode(f, code, language = language, verbose = verbose) : **
** from C:/Tools/R-4.2.2/library/StanHeaders/include/src/stan/model/model_header.hpp:4, from file5c48646a7ac5.cpp:14:C:/Tools/R-4.2.2/library/StanHeaders/include/stan/math/rev/core/set_zero_all_adjoints.hpp:14:13: warning: ‘void stan::math::set_zero_all_adjoints()’ defined but not used [-Wunused-function] static void set_zero_all_adjoints() { ^make: *** [C:/Tools/R-42~1.2/etc/x64/Makeconf:260: file5c48646a7ac5.o] Error 1

Error in sink(type = “output”) : invalid connection

A stan forum link said to try: install.packages(c(“StanHeaders”,“rstan”),type=“source”)

and when I did that Stan Headers ‘2.21.0.7’ was installed but rstan installation gave this errror:

C:/Tools/R-4.2.2/library/StanHeaders/include/stan/math/rev/core/set_zero_all_adjoints_nested.hpp:17:13: warning: ‘void stan::math::set_zero_all_adjoints_nested()’ defined but not used [-Wunused-function]
** static void set_zero_all_adjoints_nested() {**
** ^**
make: *** [C:/Tools/R-42~1.2/etc/x64/Makeconf:260: Module.o] Error 1
ERROR: compilation failed for package ‘rstan’
*** removing ‘C:/Tools/R-4.2.2/library/rstan’**
*** restoring previous ‘C:/Tools/R-4.2.2/library/rstan’**
Warning in install.packages :
** installation of package ‘rstan’ had non-zero exit status**

Can you advise how to eliminate the error?

Thank you

See the Getting Started Guide