Rstan 3.5.2 fails with Error in compileCode


I have upgraded my PC to windows10 (university PC) and tried to reinstall rstan.
All good until I try to run it. I get a compilation error. I run the same codes on my lap top (same win10, same Rstan and Rtools) with no problem.
Anyone with a clue about how to fix this?

Error in compileCode(f, code, language = language, verbose = verbose) :
Compilation ERROR, function(s)/method(s) not created! In file included from C:/Users/joeld/Rlibrary/rstan/include/rstan/stan_fit.hpp:18:0,
from C:/Users/joeld/Rlibrary/rstan/include/rstan/rstaninc.hpp:3,
from file41d065c97981.cpp:429:
C:/Users/joeld/Rlibrary/rstan/include/rstan/io/rlist_ref_var_context.hpp:16:18: fatal error: Rcpp.h: No such file or directory
#include <Rcpp.h>
compilation terminated.
make: *** [C:/PROGRA~1/R/R-35~1.2/etc/x64/Makeconf:215: file41d065c97981.o] Error 1
In addition: Warning message:
In system(cmd, intern = !verbose) :
running command ‘C:/PROGRA~1/R/R-35~1.2/bin/x64/R CMD SHLIB file41d065c97981.cpp 2> file41d065c97981.cpp.err.txt’ had status 1
Error in sink(type = “output”) : invalid connection

  • Operating System
    Platform: x86_64-w64-mingw32/x64 (64-bit)
    Running under: Windows 10 x64 (build 16299)

  • RStan Version
    R version 3.5.2 (2018-12-20)
    Rtools 3.5 is installed in C:\Rtools

  • Output of writeLines(readLines(file.path(Sys.getenv("HOME"), ".R/Makevars")))
    Error in file(con, “r”) : cannot open the connection
    In addition: Warning message:
    In file(con, “r”) :
    cannot open file ‘\kant\bio-u1\joeld\pc\Dokumenter/.R/Makevars’: No such file or directory

  • Output of devtools::session_info("rstan")

  • Session info ------------------
    setting value
    version R version 3.5.2 (2018-12-20)
    os Windows 10 x64
    system x86_64, mingw32
    ui Rgui
    language (EN)
    collate Norwegian Bokmål_Norway.1252
    ctype Norwegian Bokmål_Norway.1252
    tz Europe/Paris
    date 2019-07-02
  • Packages –
    List of packges

[1] C:/Users/joeld/Rlibrary
[2] C:/Program Files/R/R-3.5.2/library

I would first try doing

install.packages("", repos = NULL)

but you might also have to reinstall Rcpp and some other packages RStan uses.

Hi Ben,

It works! at least rtan is running now.
I did both run the script you gave and reinstalled Rcpp.

Thanks a lot