Error in Sys.setenv(R_MAKEVARS_USER = NULL) : wrong length for argument

I tried to use rstan for the first time in a while, it is installed and libraried successfully but I keep getting the same error:
Error in Sys.setenv(R_MAKEVARS_USER = NULL) : wrong length for argument
here is the sample code I use:
example(stan_model, package = “rstan”, run.dontrun = TRUE)
here is the details of the error:
Error in Sys.setenv(R_MAKEVARS_USER = NULL) : wrong length for argument
In addition: Warning message:
In .warn_march_makevars() :
Detected -march=native in the Makevars file at ‘C:/Users/sama/Documents/.R/Makevars.win’. Compiling with the -march=native flag on windows with Rtools can cause crashes because of the compiler implementation. rstan will ignore the Makevars file until -march=native is removed. You can disable this by setting rstan_options(disable_march_warning = TRUE)

I noticed two similiar issues posted:

and

yet the steps do not work for me.It seems ok with my c++ Configuring and I am not using brms.

I’m not sure how to diagnose all the RStan install problems, but @bgoodri or @andrjohns might know.

Do you have your own make/local file? If so, I would advise checking that. You can start with an empty one and see if that runs.

You might want to try cmdstanr, which should be easier to install and maintain with the latest versions of Stan.