Installation issue: stan/lang/ast_def.cpp: No such file or directory

I’m trying to re-install Rstan after updating to 3.5.0. Even after installing all dependencies, I still get the following error message:

lang__ast_def.cpp:18:33: fatal error: stan/lang/ast_def.cpp: No such file or directory

Full output is displayed below:

> install.packages("rstan", dependencies = TRUE)
Installing package into ‘/mnt/ide0/home/dmalison/R/x86_64-redhat-linux-gnu-library/3.5’
(as ‘lib’ is unspecified)
also installing the dependency ‘shinystan’

trying URL 'https://cran.rstudio.com/src/contrib/shinystan_2.5.0.tar.gz'
Content type 'application/x-gzip' length 2400413 bytes (2.3 MB)
==================================================
downloaded 2.3 MB

trying URL 'https://cran.rstudio.com/src/contrib/rstan_2.17.3.tar.gz'
Content type 'application/x-gzip' length 747202 bytes (729 KB)
==================================================
downloaded 729 KB

* installing *source* package ‘rstan’ ...
** package ‘rstan’ successfully unpacked and MD5 sums checked
** libs
g++ -m64  -I"/usr/include/R" -DNDEBUG -I"../inst/include" -I"../inst/include/boost_not_in_BH" -I"`"/usr/lib64/R/bin/Rscript" --vanilla -e "cat(system.file('include', 'src', package = 'StanHeaders'))"`" -DBOOST_RESULT_OF_USE_TR1 -DBOOST_NO_DECLTYPE -DBOOST_DISABLE_ASSERTS -DFUSION_MAX_VECTOR_SIZE=12 -DBOOST_PHOENIX_NO_VARIADIC_EXPRESSION -I"/mnt/ide0/home/dmalison/R/x86_64-redhat-linux-gnu-library/3.5/Rcpp/include" -I"/mnt/ide0/home/dmalison/R/x86_64-redhat-linux-gnu-library/3.5/RcppEigen/include" -I"/mnt/ide0/home/dmalison/R/x86_64-redhat-linux-gnu-library/3.5/BH/include" -I"/mnt/ide0/home/dmalison/R/x86_64-redhat-linux-gnu-library/3.5/StanHeaders/include" -I/usr/local/include   -fpic  -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches   -m64 -mtune=generic  -c chains.cpp -o chains.o
g++ -m64  -I"/usr/include/R" -DNDEBUG -I"../inst/include" -I"../inst/include/boost_not_in_BH" -I"`"/usr/lib64/R/bin/Rscript" --vanilla -e "cat(system.file('include', 'src', package = 'StanHeaders'))"`" -DBOOST_RESULT_OF_USE_TR1 -DBOOST_NO_DECLTYPE -DBOOST_DISABLE_ASSERTS -DFUSION_MAX_VECTOR_SIZE=12 -DBOOST_PHOENIX_NO_VARIADIC_EXPRESSION -I"/mnt/ide0/home/dmalison/R/x86_64-redhat-linux-gnu-library/3.5/Rcpp/include" -I"/mnt/ide0/home/dmalison/R/x86_64-redhat-linux-gnu-library/3.5/RcppEigen/include" -I"/mnt/ide0/home/dmalison/R/x86_64-redhat-linux-gnu-library/3.5/BH/include" -I"/mnt/ide0/home/dmalison/R/x86_64-redhat-linux-gnu-library/3.5/StanHeaders/include" -I/usr/local/include   -fpic  -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches   -m64 -mtune=generic  -c init.cpp -o init.o
g++ -m64  -I"/usr/include/R" -DNDEBUG -I"../inst/include" -I"../inst/include/boost_not_in_BH" -I"`"/usr/lib64/R/bin/Rscript" --vanilla -e "cat(system.file('include', 'src', package = 'StanHeaders'))"`" -DBOOST_RESULT_OF_USE_TR1 -DBOOST_NO_DECLTYPE -DBOOST_DISABLE_ASSERTS -DFUSION_MAX_VECTOR_SIZE=12 -DBOOST_PHOENIX_NO_VARIADIC_EXPRESSION -I"/mnt/ide0/home/dmalison/R/x86_64-redhat-linux-gnu-library/3.5/Rcpp/include" -I"/mnt/ide0/home/dmalison/R/x86_64-redhat-linux-gnu-library/3.5/RcppEigen/include" -I"/mnt/ide0/home/dmalison/R/x86_64-redhat-linux-gnu-library/3.5/BH/include" -I"/mnt/ide0/home/dmalison/R/x86_64-redhat-linux-gnu-library/3.5/StanHeaders/include" -I/usr/local/include   -fpic  -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches   -m64 -mtune=generic  -c lang__ast_def.cpp -o lang__ast_def.o
lang__ast_def.cpp:18:33: fatal error: stan/lang/ast_def.cpp: No such file or directory
 #include <stan/lang/ast_def.cpp>
                                 ^
compilation terminated.
make: *** [lang__ast_def.o] Error 1
ERROR: compilation failed for package ‘rstan’
* removing ‘/mnt/ide0/home/dmalison/R/x86_64-redhat-linux-gnu-library/3.5/rstan’
Warning in install.packages :
  installation of package ‘rstan’ had non-zero exit status
ERROR: dependency ‘rstan’ is not available for package ‘shinystan’
* removing ‘/mnt/ide0/home/dmalison/R/x86_64-redhat-linux-gnu-library/3.5/shinystan’
Warning in install.packages :
  installation of package ‘shinystan’ had non-zero exit status

The downloaded source packages are in
	‘/home/dmalison/bin/JMP/work/RtmpWita53/downloaded_packages’

It looks as if you need to first do install.packages("StanHeaders") for some reason

Hi Ben,

StanHeaders is installed but still getting same error message. Here is a list of all packages I currently have installed:

  >as.character(installed.packages()[,"Package"])
  [1] "assertthat"   "base64enc"    "bayesplot"    "BH"           "bindr"        "bindrcpp"     "bitops"       "cli"         
  [9] "colorspace"   "colourpicker" "crosstalk"    "curl"         "data.table"   "devtools"     "dichromat"    "digest"      
 [17] "dplyr"        "DT"           "dygraphs"     "ggplot2"      "ggridges"     "glue"         "gridExtra"    "gtable"      
 [25] "gtools"       "htmltools"    "htmlwidgets"  "httpuv"       "igraph"       "inline"       "labeling"     "later"       
 [33] "lazyeval"     "loo"          "matrixStats"  "mime"         "miniUI"       "munsell"      "packrat"      "pillar"      
 [41] "pkgconfig"    "PKI"          "plogr"        "plyr"         "promises"     "purrr"        "RColorBrewer" "Rcpp"        
 [49] "RcppEigen"    "RCurl"        "reshape2"     "RJSONIO"      "rlang"        "rsconnect"    "rstantools"   "RUnit"       
 [57] "scales"       "shinyjs"      "shinythemes"  "StanHeaders"  "stringi"      "threejs"      "tibble"       "tidyselect"  
 [65] "utf8"         "viridisLite"  "xts"          "zoo"          "base"         "BH"           "boot"         "car"         
 [73] "class"        "cluster"      "codetools"    "compiler"     "crayon"       "curl"         "datasets"     "devtools"    
 [81] "digest"       "doMPI"        "evaluate"     "foreach"      "foreign"      "git2r"        "graphics"     "grDevices"   
 [89] "grid"         "highr"        "htmltools"    "htmlwidgets"  "httpuv"       "httr"         "IRdisplay"    "IRkernel"    
 [97] "iterators"    "itertools"    "jsonlite"     "KernSmooth"   "knitr"        "lattice"      "lme4"         "magrittr"    
[105] "markdown"     "MASS"         "matlib"       "Matrix"       "MatrixModels" "memoise"      "methods"      "mgcv"        
[113] "mime"         "minqa"        "nlme"         "nloptr"       "nnet"         "openssl"      "parallel"     "pbdZMQ"      
[121] "pbkrtest"     "quantreg"     "R6"           "randomForest" "Rcpp"         "RcppEigen"    "repr"         "rgl"         
[129] "Rmpi"         "rpart"        "rstudioapi"   "shiny"        "snow"         "sourcetools"  "SparseM"      "spatial"     
[137] "splines"      "stats"        "stats4"       "stringi"      "stringr"      "survival"     "tcltk"        "tools"       
[145] "utils"        "uuid"         "whisker"      "withr"        "xtable"       "yaml"

What is packageVersion("StanHeaders")? Regardless, you may need to uninstall and reinstall it.

Reinstalling StanHeaders worked - thank you!