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.