Cannot install new packages in R on Windows 10

  compiler-errors, installation, r, rstudio, windows

I hit a problem trying to install a new package on Windows 10 for R 3.6. The problem seems to be the fact that R and Rtools are under ‘Program Files’, which contains a space. I haven’t been able to locate the file that cannot parse this location.

> install.packages("rJava")
Installing package into ‘C:/Users/user.name/R/lib’
(as ‘lib’ is unspecified)

  There is a binary version available but the source version is later:
      binary source needs_compilation
rJava  1.0-4  1.0-5              TRUE

installing the source package ‘rJava’

trying URL 'https://cran.rstudio.com/src/contrib/rJava_1.0-5.tar.gz'
Content type 'application/x-gzip' length 1042083 bytes (1017 KB)
downloaded 1017 KB

* installing *source* package 'rJava' ...
** package 'rJava' successfully unpacked and MD5 sums checked
** using staged installation
Generate Windows-specific files (src/jvm-w32) ...
make: Entering directory '/cygdrive/c/Users/USER~1.NAME/AppData/Local/Temp/RtmpmcDx16/R.INSTALL3754250d521e/rJava/src/jvm-w32'
C:/Program Files/Rtools/mingw_64/bin/dlltool --as C:/Program Files/Rtools/mingw_64/bin/as  --input-def jvm64.def --kill-at --dllname jvm.dll --output-lib libjvm.dll.a
make: C:/Program: Command not found
make: *** [Makefile:20: libjvm.dll.a] Error 127
make: Leaving directory '/cygdrive/c/Users/USER~1.NAME/AppData/Local/Temp/RtmpmcDx16/R.INSTALL3754250d521e/rJava/src/jvm-w32'
ERROR: configuration failed for package 'rJava'
* removing 'C:/Users/user.name/R/lib/rJava'
* restoring previous 'C:/Users/user.name/R/lib/rJava'
Warning in install.packages :
  installation of package ‘rJava’ had non-zero exit status

The downloaded source packages are in
    ‘C:Usersuser.nameAppDataLocalTempRtmpmS2d1ndownloaded_packages’

So some make file appears to have trouble reading filenames containing spaces. For Unix-like systems it is

What I found is this Github issue. I followed the steps and added SHELL=cmd.exe to the C:Program FilesRetcx64Makeconf file. This worked in the sense that this error disappeared, but now I have another error:

> install.packages("rJava")
Installing package into ‘C:/Users/user.name/R/lib’
(as ‘lib’ is unspecified)

  There is a binary version available but the source version is later:
      binary source needs_compilation
rJava  1.0-4  1.0-5              TRUE

installing the source package ‘rJava’

trying URL 'https://cran.rstudio.com/src/contrib/rJava_1.0-5.tar.gz'
Content type 'application/x-gzip' length 1042083 bytes (1017 KB)
downloaded 1017 KB

* installing *source* package 'rJava' ...
** package 'rJava' successfully unpacked and MD5 sums checked
** using staged installation
Generate Windows-specific files (src/jvm-w32) ...
make: Entering directory '/cygdrive/c/Users/USER~1.NAME/AppData/Local/Temp/RtmpEpp52V/R.INSTALL35348a31273/rJava/src/jvm-w32'
The system cannot find the path specified.
C:/Program Files/Rtools/mingw_64/bin/dlltool --as C:/Program Files/Rtools/mingw_64/bin/as  --input-def jvm.def --kill-at --dllname jvm.dll --output-lib libjvm.dll.a
'tools' is not recognized as an internal or external command,
operable program or batch file.
make: *** [Makefile:20: libjvm.dll.a] Error 1
make: Leaving directory '/cygdrive/c/Users/USER~1.NAME/AppData/Local/Temp/RtmpEpp52V/R.INSTALL35348a31273/rJava/src/jvm-w32'
ERROR: configuration failed for package 'rJava'
* removing 'C:/Users/user.name/R/lib/rJava'
* restoring previous 'C:/Users/user.name/R/lib/rJava'
Warning in install.packages :
  installation of package ‘rJava’ had non-zero exit status

I am using R version 3.6 and due to dependency issues cannot really install a newer version of R. The version information that RStudio shows at the top of the console when launching the RStudio:

R version 3.6.1 (2019-07-05) -- "Action of the Toes"
Copyright (C) 2019 The R Foundation for Statistical Computing
Platform: x86_64-w64-mingw32/x64 (64-bit)

Rtools version is 3.5.0.4.

Source: Windows Questions

LEAVE A COMMENT