1

I am trying to install rstan but am coming up with immense difficulty trying to install packages from source. I am currently running R version 4.3.0 (windows 11, 64 bit) and have installed rtools43.

To illustrate the problem, if I try and run this command:

install.packages("Rcpp", type="source")

I get this output:

Warning in install.packages : installation of package ‘Rcpp’ had non-zero exit status

I am completely stuck on this. I have tried reinstalling R, RStudio and rtools multiple times and I also tried installing an earlier version of R and rtools42. This also did not fix the problem. ChatGPT was also not much help here either.

If someone could help me troubleshoot this, I would be extremely grateful as I really could do with getting rstan working.

Phil
  • 7,287
  • 3
  • 36
  • 66
Ruben222
  • 11
  • 2
  • 2
    Install rtools43 instead of rtools42, and try without the argument `type = "source"`. – Phil May 03 '23 at 14:09
  • 3
    Was there no other error at all before that? That was the only output you received? Normally there's more descriptive output that tells you what exactly went wrong. Maybe run `pkgbuild::has_rtools(debug=TRUE)` if you can install `pkgbuild` to make sure Rtools is installed properly. – MrFlick May 03 '23 at 14:18
  • Why source? You can install 'pre-made, ready-to-use, binary` packages for both `Rcpp` and `rstan` from CRAN which, even if they come as binaries, should allow you to run stan models involving compilation. As for 'source install is failing me': Not an `Rcpp`. The package install _if your setup is correct_ and how to get there on Windows (or other specific OS instances) is described in many places. – Dirk Eddelbuettel May 03 '23 at 14:56
  • 1
    You do not even need `pkgbuild`. Install `Rcpp` has a binary from CRAN. Then run `Rcpp::evalCpp("21 + 21")` and the official answer to all things should appear. If not, you have R / Rtools / ... issues you need to address locally. – Dirk Eddelbuettel May 03 '23 at 14:57
  • Thanks for the replies. I need to install from source because the binary package has a known issue (explained here - https://github.com/stan-dev/rstan/wiki/RStan-Getting-Started). I currently have rtools43 installed and R version 4.3.0. – Ruben222 May 03 '23 at 17:06
  • The output from```pkgbuild::has_rtools(debug=TRUE)``` is weird. I get this: ```WARNING: Rtools is required to build R packages, but no version of Rtools compatible with R 4.3.0 was found. (Only the following incompatible version(s) of Rtools were found: 4.3.5550)``` ```Please download and install Rtools 4.2 from https://cran.r-project.org/bin/windows/Rtools/ or https://www.r-project.org/nosvn/winutf8/ucrt3/.``` – Ruben222 May 03 '23 at 17:07
  • Sorry, I missed @MrFlick's question. No, there are no other errors. The output from attempting to install the Rcpp package from source is literally just: ```trying URL 'https://cran.rstudio.com/src/contrib/Rcpp_1.0.10.tar.gz' Content type 'application/x-gzip' length 2936173 bytes (2.8 MB) downloaded 2.8 MB``` ```Warning in install.packages : installation of package ‘Rcpp’ had non-zero exit status``` ```The downloaded source packages are in ‘C:\Users\user\AppData\Local\Temp\Rtmpk1UnY6\downloaded_packages’``` – Ruben222 May 04 '23 at 09:56
  • 1
    Sorry to bump this thread, but I am still having difficulties with this. If anybody does have any ideas or could help me troubleshoot this, I would be really grateful. – Ruben222 May 10 '23 at 08:08

0 Answers0