Search code examples
rreporters

Error installing 'ReporteRs' and 'ReporteRsjars'


Ultimately I am attempting to install the R package ReporteRs (ReporteRs_0.8.7.tar.gz) on a Windows 7 system (session info, and other info below). This depends on the package ReporteRsjars (ReporteRsjars_0.0.2.tar.gz) which is where I am getting the install error.

This also depends on the R package rJava which is installed, along with JDK/JRE (jre1.8.0_112).

I am installing on a machine that has no internet access so I am doing this from a local version of CRAN with the PACKAGES and PACKAGES.gz built. This has been working without any issues (at least now it is).

rJava loads without any issues but when installing ReporteRsjars, I get the error below (see Install Attempt ERROR below).

NOTE: Other StackOverflow questions seem more focussed around library(rJava) having issues, not when installing a package dependent on rJava.

The rJava DLL is in the following location:

C:/Program Files/R/R-3.3.2/library/rJava/libs/x64/rJava.dll

This was reinstalled a number of times (successfully).

The sessionInfo and a more information is below the error (including what I tried).

Install Attempt ERROR

cran_dir_url is set to the path where the CRAN packages are located. This is prefixed with file://

> library(rJava)
> install.packages('ReporteRsjars', contriburl=cran_dir_url, repos = cran_dir_url, type = 'source')

## * installing *source* package 'ReporteRsjars' ...
## ** package 'ReporteRsjars' successfully unpacked and MD5 sums checked
## ** R
## ** inst
## ** preparing package for lazy loading
## ** help
## No man pages found in package  'ReporteRsjars' 
## *** installing help indices
## ** building package indices
## ** testing if installed package can be loaded
## *** arch - i386
## Error : .onLoad failed in loadNamespace() for 'rJava', details:
##   call: library.dynam("rJava", pkgname, libname)
##   error: DLL 'rJava' not found: maybe not installed for this architecture?
## Error: loading failed
## Execution halted
## *** arch - x64
## ERROR: loading failed for 'i386'
## * removing 'C:/Program Files/R/R-3.3.2/library/ReporteRsjars'
## Warning in install.packages :
##   running command '"C:/PROGRA~1/R/R-33~1.2/bin/x64/R" CMD INSTALL -l "C:\Program Files\R\R-3.3.2\library" /Users/cirina_ext/Documents/StevenBanville/CRAN_Targeted/ReporteRsjars_0.0.2.tar.gz' had status 1
## Warning in install.packages :
##   installation of package 'ReporteRsjars' had non-zero exit status
## 

Environment Information & Tools

Path Info: The following is included in the system path and is where Java was installed.

C:\Program Files\Java\jre1.8.0_112\bin\;C:\Program Files\Java\jre1.8.0_112\bin\server\;%path%

(JDK Installer: jdk-8u112-windows-x64)

Rtools Version and Location

Version: 3.4.0.1962 Location: C:\Rtools

What I Tried

  • I started with attempting to install the ReporteRs R packages, and this installed all dependencies but failed on the ReporteRsjars package.

  • After installing the JDK/JRE, I reinstalled rJava (this was done a few times after various attempts to install the R package). All rJava installs were successful, and so was library(rJava).

  • I attempted to run the following command in a windows command window, as I have seen this recommended in a number of SO answers.

    R CMD javareconf

    'javareconf' is not recognized as an internal or external command, operable program or batch file.

  • I attempted to include the path to the rJava DLL in the path system variable but that did not work.

  • NOTE: I restarted the RGui and RStudio after each of these attempts (I tried in both of these environments). I also rebooted the machine.

  • I have done a lot of googling and looking at StackOverflow but all of the issues have found are not the same as this. They appear similar but after attempting a number of things, I still get the above error. I have omitted the links I looked at but can add them if that would help.

An guidance to help me troubleshoot and solve this would be appreciated.

Session Info

> sessionInfo('rJava')
## R version 3.3.2 (2016-10-31)
## Platform: x86_64-w64-mingw32/x64 (64-bit)
## Running under: Windows 7 x64 (build 7601) Service Pack 1
## 
## locale:
## [1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252   
## [3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C                          
## [5] LC_TIME=English_United States.1252    
## 
## attached base packages:
## character(0)
## 
## other attached packages:
## [1] rJava_0.9-8
## 
## loaded via a namespace (and not attached):
## [1] graphics_3.3.2  tools_3.3.2     utils_3.3.2     grDevices_3.3.2 stats_3.3.2     datasets_3.3.2 
## [7] methods_3.3.2   base_3.3.2     

EDIT

I attempted the same install on a different machine with only the 64 bit version of Java (and confirmed it is 64 bit) and got the same error. Here is a snippet but it is the same as the above error:

...
*** arch - i386
Error : .onLoad failed in loadNamespace() for 'rJava', details:
  call: library.dynam("rJava", pkgname, libname)
  error: DLL 'rJava' not found: maybe not installed for this architecture?
Error: loading failed
Execution halted
...

I am still looking at the link from the comment by @42-, but this doesn't look like an issue with the JRE/JDK not being 64 bit.

EDIT 2

Note: this is not posted as an answer since it is just a workaround.

I found a workaround which is not quite desirable. It seems the install from the local CRAN copy was not quite as similar as I had expected. I installed the problematic library install(s) on an equivalent Windows 7 machine using a NON-local CRAN (i.e. the usual way) and copied the directories to the other machine (i.e. the machine not connected to the internet). This appears to have worked but it is not clear why the other method did not (local CRAN copy with updated PACKAGES file). The one thing I noticed is, when hitting the usual CRAN repository, it used .zip versions of the libraries and not the tar.gz; I am not sure if that matters.

EDIT 3

Based on the response from David Gohel in the this ReporteRs Issues, the following code with the INSTALL_opts = "--no-multiarch" added may fix the issue:

install.packages("ReporteRs", contriburl=cran_dir_url,
                 repos = cran_dir_url, 
                 type = 'source', INSTALL_opts = "--no-multiarch")

I will add this as an answer if I determine that it would fix the issue, however, I have already implemented the workaround mentioned in EDIT 2.


Solution

  • Based on the response from David Gohel in this GitHub ReporteRs Issues, the following code with the INSTALL_opts = "--no-multiarch" added, fixed the issue I was having:

    install.packages("ReporteRs", contriburl=cran_dir_url,
                     repos = cran_dir_url, 
                     type = 'source',
                     INSTALL_opts = "--no-multiarch")
    

    Edit

    The variable cran_dir_url should point to a directory that contains the .tar.gz install package files. Two examples of paths that could be used are the following:

    # (*) Web: URL pointing to CRAN
    cran_dir_url <- "https://cloud.r-project.org/src/contrib"
    
    # (*) Local: Pointing to local copy of CRAN (or whatever local packages you
    # would like to install).
    # Note: this example is a Mac OS path with username "someuser".
    # Note: the three "/" chars are correct ("file://" followed by "/Users/..." => "file:///Users/..."
    cran_dir_url <- "file:///Users/someuser/CRAN_Local/"
    
    

    Inside of the above two paths (http and file), there will be .tar.gz files (e.g. ggplot2_3.3.5.tar.gz).