Error in compileCode(f, code, language = language, verbose = verbose) : make: NUL: No such file or directorymake: *** No rule to make target 'NUL'. Stop

Try to run stan model:

example(stan_model, package = "rstan", run.dontrun = TRUE)

and getting the error message:

Compilation ERROR, function(s)/method(s) not created!
Error in compileCode(f, code, language = language, verbose = verbose) : 
  C:/rtools40/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/Users/nmuravskaya/Documents/R/R-4.0.5/library/rstan/lib/x64/libStanServices.a(stan_fit.o):stan_fit.cpp:(.data$_ZZN5boost4math6detail9bessel_j0IeEET_S3_E2P1[_ZZN5boost4math6detail9bessel_j0IeEET_S3_E2P1]+0x0): multiple definition of `boost::math::detail::bessel_j0<long double>(long double)::P1'; file24703bb523a4.o:file24703bb523a4.cpp:(.rdata$_ZZN5boost4math6detail9bessel_j0IeEET_S3_E2P1[_ZZN5boost4math6detail9bessel_j0IeEET_S3_E2P1]+0x0): first defined hereC:/rtools40/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/Users/nmuravskaya/Documents/R/R-4.0.5/library/rstan/lib/x64/libStanServices.a(stan_fit.o):stan_fit.cpp:(.data$_ZZN5boost4math6detail9bessel_j0IeEET_S3_E2QS[_ZZN5boost4math6detail9bessel_j0IeEET_S3_E2QS]+0x0): multiple definition of `boost::math::detail::bessel_j0<long double>(long double)::QS'; file24703bb523a4.o:fi
In addition: Warning message:
In system(paste(CXX, ARGS), ignore.stdout = TRUE, ignore.stderr = TRUE) :
  'C:/rtools40/usr/mingw_/bin/g++' not found

Seems like my question relates to installation so there is following information:

  • Operating System: Windows 10 Enterprise, 64-bit OS, x64-based processor
  • RStan Version: 2.21.2
  • Output of writeLines(readLines(file.path(Sys.getenv("HOME"), ".R/Makevars"))) - n/a
  • Output of devtools::session_info("rstan"):
- Session info ---------------------------------------------------------------------------------------------------------------------
 setting  value                       
 version  R version 4.0.5 (2021-03-31)
 os       Windows >= 8 x64            
 system   x86_64, mingw32             
 ui       RStudio                     
 language (EN)                        
 collate  English_United States.1252  
 ctype    English_United States.1252  
 tz       America/Los_Angeles         
 date     2021-05-20                  

- Packages -------------------------------------------------------------------------------------------------------------------------
 package      * version   date       lib source        
 backports      1.2.1     2020-12-09 [1] CRAN (R 4.0.3)
 BH             1.75.0-0  2021-01-11 [1] CRAN (R 4.0.3)
 callr          3.7.0     2021-04-20 [1] CRAN (R 4.0.5)
 checkmate      2.0.0     2020-02-06 [1] CRAN (R 4.0.2)
 cli            2.5.0     2021-04-26 [1] CRAN (R 4.0.5)
 colorspace     2.0-1     2021-05-04 [1] CRAN (R 4.0.5)
 crayon         1.4.1     2021-02-08 [1] CRAN (R 4.0.5)
 curl           4.3.1     2021-04-30 [1] CRAN (R 4.0.5)
 desc           1.3.0     2021-03-05 [1] CRAN (R 4.0.5)
 digest         0.6.27    2020-10-24 [1] CRAN (R 4.0.5)
 ellipsis       0.3.2     2021-04-29 [1] CRAN (R 4.0.5)
 fansi          0.4.2     2021-01-15 [1] CRAN (R 4.0.5)
 farver         2.1.0     2021-02-28 [1] CRAN (R 4.0.5)
 ggplot2      * 3.3.3     2020-12-30 [1] CRAN (R 4.0.5)
 glue           1.4.2     2020-08-27 [1] CRAN (R 4.0.5)
 gridExtra      2.3       2017-09-09 [1] CRAN (R 4.0.2)
 gtable         0.3.0     2019-03-25 [1] CRAN (R 4.0.2)
 inline         0.3.17    2020-12-01 [1] CRAN (R 4.0.5)
 isoband        0.2.4     2021-03-03 [1] CRAN (R 4.0.5)
 jsonlite       1.7.2     2020-12-09 [1] CRAN (R 4.0.5)
 labeling       0.4.2     2020-10-20 [1] CRAN (R 4.0.3)
 lattice        0.20-44   2021-05-02 [1] CRAN (R 4.0.5)
 lifecycle      1.0.0     2021-02-15 [1] CRAN (R 4.0.5)
 loo            2.4.1     2020-12-09 [1] CRAN (R 4.0.5)
 magrittr       2.0.1     2020-11-17 [1] CRAN (R 4.0.5)
 MASS           7.3-54    2021-05-03 [1] CRAN (R 4.0.5)
 Matrix         1.2-18    2019-11-27 [1] CRAN (R 4.0.3)
 matrixStats    0.58.0    2021-01-29 [1] CRAN (R 4.0.5)
 mgcv           1.8-35    2021-04-18 [1] CRAN (R 4.0.5)
 munsell        0.5.0     2018-06-12 [1] CRAN (R 4.0.2)
 nlme           3.1-152   2021-02-04 [1] CRAN (R 4.0.5)
 pillar         1.6.1     2021-05-16 [1] CRAN (R 4.0.2)
 pkgbuild       1.2.0     2020-12-15 [1] CRAN (R 4.0.5)
 pkgconfig      2.0.3     2019-09-22 [1] CRAN (R 4.0.2)
 prettyunits    1.1.1     2020-01-24 [1] CRAN (R 4.0.2)
 processx       3.5.2     2021-04-30 [1] CRAN (R 4.0.5)
 ps             1.6.0     2021-02-28 [1] CRAN (R 4.0.5)
 R6             2.5.0     2020-10-28 [1] CRAN (R 4.0.5)
 RColorBrewer   1.1-2     2014-12-07 [1] CRAN (R 4.0.0)
 Rcpp           1.0.6     2021-01-15 [1] CRAN (R 4.0.5)
 RcppEigen      0.3.3.9.1 2020-12-17 [1] CRAN (R 4.0.5)
 RcppParallel   5.1.4     2021-05-04 [1] CRAN (R 4.0.5)
 rlang          0.4.11    2021-04-30 [1] CRAN (R 4.0.5)
 rprojroot      2.0.2     2020-11-15 [1] CRAN (R 4.0.5)
 rstan        * 2.21.2    2020-07-27 [1] CRAN (R 4.0.2)
 scales         1.1.1     2020-05-11 [1] CRAN (R 4.0.2)
 StanHeaders  * 2.21.0-7  2020-12-17 [1] CRAN (R 4.0.5)
 tibble         3.1.1     2021-04-18 [1] CRAN (R 4.0.5)
 utf8           1.2.1     2021-03-12 [1] CRAN (R 4.0.5)
 V8             3.4.2     2021-05-01 [1] CRAN (R 4.0.5)
 vctrs          0.3.8     2021-04-29 [1] CRAN (R 4.0.5)
 viridisLite    0.4.0     2021-04-13 [1] CRAN (R 4.0.5)
 withr          2.2.0     2020-04-20 [1] CRAN (R 4.0.5)

[1] C:/Users/nmuravskaya/Documents/R/R-4.0.5/library

I had a look at the other similar posts, but they have not worked for me. Any advise would be most appreciated.

Hi Namaruva,

You just need to reinstall rstan and StanHeaders from source. Try restarting R (making sure that rstan doesn’t get loaded) and run:

# Compile packages using all cores
Sys.setenv(MAKEFLAGS = paste0("-j",parallel::detectCores()))

remove.packages(c("StanHeaders","rstan"))
install.packages(c("StanHeaders","rstan"),type="source")
1 Like

Thanks @andrjohns!
Actually, the problem was fixed via an approach from your post from here.
Thanks again for your help!