r-windows / docs

Documentation for rtools40 and R for Windows
31 stars 10 forks source link

Can't install CRAN packages from source - fails with no error message #33

Closed znmeb closed 2 years ago

znmeb commented 2 years ago

This is on 64=bit R for Windows GUI, not in RStudio. It also fails in RStudio and fails for packages besides jsonlite but this is the simplest case I can reproduce.

R version 4.1.2 (2021-11-01) -- "Bird Hippie"
Copyright (C) 2021 The R Foundation for Statistical Computing
Platform: x86_64-w64-mingw32/x64 (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

  Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> Sys.which("make")
                              make 
"C:\\rtools40\\usr\\bin\\make.exe" 
> Sys.getenv("RTOOLS40_HOME")
[1] "C:\\rtools40"
> install.packages("jsonlite", type = "source")
Installing package into ‘C:/Users/znmeb/R/win-library/4.1’
(as ‘lib’ is unspecified)
--- Please select a CRAN mirror for use in this session ---
trying URL 'https://cloud.r-project.org/src/contrib/jsonlite_1.7.2.tar.gz'
Content type 'application/x-gzip' length 421716 bytes (411 KB)
downloaded 411 KB

The downloaded source packages are in
        ‘C:\Users\znmeb\AppData\Local\Temp\RtmpG2umGc\downloaded_packages’
Warning message:
In install.packages("jsonlite", type = "source") :
  installation of package ‘jsonlite’ had non-zero exit status
> 

Here's "~/.Renviron"

PATH="${RTOOLS40_HOME}\usr\bin;${PATH}"

There's no error message, even if I use verbose = TRUE and keep_outputs = TRUE.

jeroen commented 2 years ago

Is maybe your home directory unwriteable? C:/Users/znmeb/R/win-library/4.1 ? Does installing the binary package work?

znmeb commented 2 years ago

The home library is writeable and binary packages work. This is a new phenomenon; I'm sure it's some kind of screwed-up environment / PATH problem that would be obvious if the install logs were available. Is there any way to force them? "verbose" and "keep_outputs" either isn't working or it's putting the logs somewhere obscure.

znmeb commented 2 years ago

I have it working finally. It looks like what was happening is that "cmd.exe" was corrupted or one of its dependencies was missing. I couldn't even start "cmd.exe" from the Start menu. I had to reset the PC from the recovery menu to get that fixed. Once I got that fixed I could install jsonlite from source.