1

Even when reinstalling R from scratch, I cannot install source packages with tar.gz files. Other users are also stuck at this step, which is highly annoying. I manage to do install R packages from source on my personal laptop, which has R4.3.1 and Rtools4.3 installed. So basically the same configuration that on my work laptop, but it does not work on my work laptop.

This is creating issues for other packages such as brms or rstan. I do not want to experiment with my personal laptop, in case I would be stuck with the same issue as on my work laptop. By the way, everything was also working fine on my work laptop before. I just do not know what happened, but one day I could not install any packages from source. Very weird and very difficult to find an answer online, even though many people seem to be affected by similar issues. This is not specific to any package and so the solution should be very general, but I cannot find it.

I tried to really take it step by step for the installation.

To ensure that I had a clean laptop without traces of previous R / Rtools / RStudio installations, I followed the instructions here.

Then, I first install R4.3.1. Then, I create a writeable path to store my packages (C:/R/library). The paths are recognized by R:

.libPaths()
[1] "C:/R/library"                       "C:/Program Files/R/R-4.3.1/library"

To illustrate the problem, here is the output when I try to install PKI from source:

install.packages("PKI", type = "source")
Installing package into ‘C:/R/library’
(as ‘lib’ is unspecified)
also installing the dependency ‘base64enc’

trying URL 'https://packages.othr.de/cran/src/contrib/base64enc_0.1-3.tar.gz'
Content type 'text/plain' length 7833 bytes
downloaded 7833 bytes

trying URL 'https://packages.othr.de/cran/src/contrib/PKI_0.1-12.tar.gz'
Content type 'text/plain' length 85544 bytes (83 KB)
downloaded 83 KB


The downloaded source packages are in
        ‘C:\Users\User Name\AppData\Local\Temp\RtmpquNT2s\downloaded_packages’
Warning messages:
1: In install.packages("PKI", type = "source") :
  installation of package ‘base64enc’ had non-zero exit status
2: In install.packages("PKI", type = "source") :
  installation of package ‘PKI’ had non-zero exit status

The .tar.gz files are downloaded and stored in the specified folder, but then nothing happens. The process is stuck.

I tried to untar the files and export them in the library folder:

untar("C:/Users/User Name/AppData/Local/Temp/RtmpquNT2s/downloaded_packages/base64enc_0.1-3.tar.gz", exdir = "C:/R/library")

The process works: the .tar.gz file is untarred in the correct folder. But this is obviously not the right way to install the package, as when I try to run the library(base64enc) command, I get the following error:

library(base64enc)
Error in library(base64enc) : 
  ‘base64enc’ is not a valid installed package

After installing the pkgbuild package, I check whether there is a problem with Rtools, but Rtools seems to be found and should be running:

install.packages("pkgbuild")
library(pkgbuild)

rtools_path()
[1] "C:\\rtools43/usr/bin"

has_rtools(debug = TRUE)
Found in Rtools 4.3 installation folder
[1] TRUE

check_rtools(debug = TRUE)
Found in Rtools 4.3 installation folder
[1] TRUE 

Any help would be appreciated. Many thanks in advance.

Here is the information about my session:

sessionInfo()
R version 4.3.1 (2023-06-16 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19045)

Matrix products: default


locale:
[1] LC_COLLATE=English_United Kingdom.utf8  LC_CTYPE=English_United Kingdom.utf8    LC_MONETARY=English_United Kingdom.utf8 LC_NUMERIC=C                            LC_TIME=English_United Kingdom.utf8    

time zone: Europe/Zurich
tzcode source: internal

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] pkgbuild_1.4.2

loaded via a namespace (and not attached):
[1] processx_3.8.2    compiler_4.3.1    R6_2.5.1          cli_3.6.1         prettyunits_1.1.1 tools_4.3.1       crayon_1.5.2      callr_3.7.3       ps_1.7.5

Let me know whether I need to provide more information.

  • I would take a careful look at Dirk E's comments on the linked issue. There's a number of updates to compilers and compiler-related libs that have to be followed carefully. Hop on over to CRAN and read through their instructions for installing packages from source on Windows machines. – Carl Witthoft Aug 25 '23 at 18:44
  • Thanks @CarlWitthoft. I had another careful look at Dirk E's comment, which states that "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." – KrisAnathema Aug 28 '23 at 07:57
  • Here is the output I get: ` Rcpp::evalCpp("21 + 21") Error in sourceCpp(code = code, env = env, rebuild = rebuild, cacheDir = cacheDir, : Error 65535 occurred building shared library. WARNING: The tools required to build C++ code for R were not found. Please download and install the appropriate version of Rtools: http://cran.r-project.org/bin/windows/Rtools/` Which confirms that my issue is with the installation of R / Rtools. A problem I cannot solve by uninstalling/reinstalling R and that I do not have on my personal laptop. – KrisAnathema Aug 28 '23 at 07:57
  • From the CRAN help pages, [6.3 Installing packages / 6.3.1 Windows](https://cran.r-project.org/) and [3.1.1 The Windows toolset](https://cran.r-project.org/doc/manuals/r-release/R-admin.html#The-Windows-toolset), I do not see how to deal with my issues. I thought that totally uninstalling R and reinstalling from scratch would solve of potential conflicts with path names, environments and so on. But it seems this is not the case. It would be good to know how to check for that. When I run `Sys.getenv()`, it seems like everything is well configured, but something is surely not working right. – KrisAnathema Aug 28 '23 at 08:53

0 Answers0