eheisman/dssrip

ERROR: lazy loading failed for package

SwampThingPaul opened this issue · 9 comments

I am trying to install the dssrip package and keep getting ERROR: lazy loading failed for package 'dssrip' .

I have updated all the dependant packages (rJava, etc) and have DSSVue 2.0.1 installed. I am running 32-bit R-version 3.6.1.

Any guidance would be appreciated.

Is there any error messages above that one? I'm not familiar with the term 'lazy loading', but a quick Google search suggests there are a few issues with my code that might cause this error. If there is more of an error message that might help me track down the specific issue and figure out how to address it.

This stackoverflow post suggests a missing function argument somewhere and having code that lives outside of a function definition as two possible causes. I know that the code outside of a function issue might be occuring in the initialization code for dssrip.

I don't believe I've tested dssrip on anything newer than 3.4.

Here is the full error:

> devtools::install_github("eheisman/dssrip", INSTALL_opts = "--no-multiarch")
Downloading GitHub repo eheisman/dssrip@master
√  checking for file 'C:\Users\julian_p\AppData\Local\Temp\RtmpG2LXKD\remotes31e074ac1441\eheisman-dssrip-fad0ac8/DESCRIPTION' (840ms)
-  preparing 'dssrip':
√  checking DESCRIPTION meta-information ... 
-  checking for LF line-endings in source and make files and shell scripts
-  checking for empty or unneeded directories
-  building 'dssrip_0.1.tar.gz'
   
Installing package into ‘C:/Users/julian_p/Documents/R/win-library/3.6’
(as ‘lib’ is unspecified)
* installing *source* package 'dssrip' ...
** using staged installation
** R
** demo
** byte-compile and prepare package for lazy loading
Error: (converted from warning) package 'rJava' was built under R version 3.6.3
Execution halted
ERROR: lazy loading failed for package 'dssrip'
* removing 'C:/Users/julian_p/Documents/R/win-library/3.6/dssrip'
Error: Failed to install 'dssrip' from GitHub:
  (converted from warning) installation of package ‘C:/Users/julian_p/AppData/Local/Temp/RtmpG2LXKD/file31e01f294275/dssrip_0.1.tar.gz’ had non-zero exit status

Are you using the somewhat hidden functionality to write to DSS files, or only reading from them? I ask because my fix might make writing no longer work.

Please give the 'tidyup' branch a try - I removed the code to write out DSS timeseries, which was pretty messy in trying to get the metadata right. This has been the source of most of my previous issues getting the package to load.

I also removed bunch of functions related to plotting and goodness-of-fit that are maintained in the hydroutil package.

I am just using the package to read DSS files. I tried installing the tidyup branch and still got the warning.

> devtools::install_github("eheisman/dssrip",ref="tidyup", INSTALL_opts = "--no-multiarch")
Downloading GitHub repo eheisman/dssrip@tidyup
√  checking for file 'C:\Users\julian_p\AppData\Local\Temp\RtmpMLZ7fd\remotes56c0793a4a9f\eheisman-dssrip-fbb69ee/DESCRIPTION' (543ms)
-  preparing 'dssrip':
√  checking DESCRIPTION meta-information ... 
-  checking for LF line-endings in source and make files and shell scripts
-  checking for empty or unneeded directories
-  building 'dssrip_0.1.tar.gz'
   
Installing package into ‘C:/Users/julian_p/Documents/R/win-library/3.6’
(as ‘lib’ is unspecified)
* installing *source* package 'dssrip' ...
** using staged installation
** R
** demo
** byte-compile and prepare package for lazy loading
Error: (converted from warning) package 'rJava' was built under R version 3.6.3
Execution halted
ERROR: lazy loading failed for package 'dssrip'
* removing 'C:/Users/julian_p/Documents/R/win-library/3.6/dssrip'
* restoring previous 'C:/Users/julian_p/Documents/R/win-library/3.6/dssrip'
Error: Failed to install 'dssrip' from GitHub:
  (converted from warning) installation of package ‘C:/Users/julian_p/AppData/Local/Temp/RtmpMLZ7fd/file56c011a136bf/dssrip_0.1.tar.gz’ had non-zero exit status

I was able to fork the original repo and install locally with all the functionality. I did a quick check of the forked repo using devtools::check() and got the following.

>  devtools::build()
√  checking for file 'C:\Julian_LaCie\_GitHub\dssrip/DESCRIPTION' (501ms)
-  preparing 'dssrip': (1.2s)
√  checking DESCRIPTION meta-information ... 
-  checking for LF line-endings in source and make files and shell scripts
-  checking for empty or unneeded directories
-  building 'dssrip_0.1.tar.gz'
   
[1] "C:/Julian_LaCie/_GitHub/dssrip_0.1.tar.gz"
> devtools::check()
-- Building ---------------------------------------------------------- dssrip --
Setting env vars:
* CFLAGS    : -Wall -pedantic
* CXXFLAGS  : -Wall -pedantic
* CXX11FLAGS: -Wall -pedantic
--------------------------------------------------------------------------------
√  checking for file 'C:\Julian_LaCie\_GitHub\dssrip/DESCRIPTION' (638ms)
-  preparing 'dssrip': (458ms)
√  checking DESCRIPTION meta-information ... 
-  checking for LF line-endings in source and make files and shell scripts (351ms)
-  checking for empty or unneeded directories
-  building 'dssrip_0.1.tar.gz'
   
-- Checking ---------------------------------------------------------- dssrip --
Setting env vars:
* _R_CHECK_CRAN_INCOMING_REMOTE_: FALSE
* _R_CHECK_CRAN_INCOMING_       : FALSE
* _R_CHECK_FORCE_SUGGESTS_      : FALSE
* NOT_CRAN                      : true
-- R CMD check --------------------------------------------------------------------------
-  using log directory 'C:/Users/julian_p/AppData/Local/Temp/RtmpwPiAyK/dssrip.Rcheck' (601ms)
-  using R version 3.6.1 (2019-07-05)
-  using platform: i386-w64-mingw32 (32-bit)
-  using session charset: ISO8859-1
-  using options '--no-manual --as-cran' (1.2s)
√  checking for file 'dssrip/DESCRIPTION'
-  this is package 'dssrip' version '0.1'
√  checking package namespace information ...
N  checking package dependencies (3.3s)
   Package suggested but not available for checking: 'hydroutils'
   
   Depends: includes the non-default packages:
     'rJava', 'xts', 'zoo', 'stringr', 'data.table', 'plyr'
   Adding so many packages to the search path is excessive and importing
   selectively is preferable.
√  checking if this is a source package ... 
√  checking if there is a namespace
√  checking for .dll and .exe files
√  checking for hidden files and directories ... 
√  checking for portable file names ... 
√  checking serialization versions
E  checking whether package 'dssrip' can be installed (7.8s)
   Installation failed.
   See 'C:/Users/julian_p/AppData/Local/Temp/RtmpwPiAyK/dssrip.Rcheck/00install.out' for details.
   
   See
     'C:/Users/julian_p/AppData/Local/Temp/RtmpwPiAyK/dssrip.Rcheck/00check.log'
   for details.
   
-- R CMD check results -------------------------------------------------- dssrip 0.1 ----
Duration: 13.6s

> checking whether package 'dssrip' can be installed ... ERROR
  See below...

> checking package dependencies ... NOTE
  Package suggested but not available for checking: 'hydroutils'
  
  Depends: includes the non-default packages:
    'rJava', 'xts', 'zoo', 'stringr', 'data.table', 'plyr'
  Adding so many packages to the search path is excessive and importing
  selectively is preferable.

-- Install failure ----------------------------------------------------------------------

* installing *source* package 'dssrip' ...
** using staged installation
** R
** demo
** byte-compile and prepare package for lazy loading
Warning messages:
1: package 'rJava' was built under R version 3.6.3 
2: package 'xts' was built under R version 3.6.3 
3: package 'zoo' was built under R version 3.6.3 
4: package 'stringr' was built under R version 3.6.2 
5: package 'data.table' was built under R version 3.6.2 
6: package 'plyr' was built under R version 3.6.3 
Note: possible error in 'month(d, label = TRUE, ': unused arguments (label = TRUE, abbr = TRUE) 
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded from temporary location
*** arch - i386
Warning: package 'rJava' was built under R version 3.6.3
Warning: package 'xts' was built under R version 3.6.3
Warning: package 'zoo' was built under R version 3.6.3
Warning: package 'stringr' was built under R version 3.6.2
Warning: package 'data.table' was built under R version 3.6.2
Warning: package 'plyr' was built under R version 3.6.3
*** arch - x64
Warning: package 'rJava' was built under R version 3.6.3
Error: package or namespace load failed for 'rJava':
 .onLoad failed in loadNamespace() for 'rJava', details:
  call: fun(libname, pkgname)
  error: No CurrentVersion entry in Software/JavaSoft registry! Try re-installing Java and make sure R and Java have matching architectures.
Error : package 'rJava' could not be loaded
Error: loading failed
Execution halted
ERROR: loading failed for 'x64'
* removing 'C:/Users/julian_p/AppData/Local/Temp/RtmpwPiAyK/dssrip.Rcheck/dssrip'

1 error x | 0 warnings √ | 1 note x

I wonder if it has something to do with the version of Java? I have version 8 update 201 (build 1.8.0_201-b09) if it helps.

Oh, the version of Java could be the issue. Setting the environment variable JAVA_HOME before loading the rJava package might fix this.

I originally designed this to work against DSSVue 2.0.1 because that was available on the HEC website and easy to install. have you had a chance to look at the instructions for using the 64-bit version? You can link them against a newer 64-bit HEC program (HEC-WAT works for me) which may solve the Java compatibility issues. note the last line before the code snippet below for where the options need to go to make this work.

I have a newer 64-bit version of DSSVue on my machine, along with a few other HEC programs that all seem to work for dssrip. The following code can be placed in your .RProfile file to make it find the correct versions of the HEC libraries and telling rJava to initialize with the same version of Java.

The dss_locationoption should point to the folder that contains the .jar files, the dss_jre_location option needs to point to where the java.exe to be used by rJava is located. The environment variable JAVA_HOME is used by rJava, but it's a bit of a mystery to me why 64-bit seems to work best with it unset.

if(R.Version()$arch=="x86_64"){
    # use 64-bit .jar and .dll
    options(dss_location="C:\\Program Files (x86)\\HEC\\DSSVue\\")
    options(dss_jre_location="C:\\Program Files (x86)\\HEC\\DSSVue\\java")
    #Sys.getenv("JAVA_HOME") #=options("dss_jre_location"))  # I think this should be: Sys.setenv(JAVA_HOME=""), but works anyway because not set for 64-bit.
} else {
    # use 32-bit libraries, dssrip probably doesn't interpret this right, doens't know to look for dss_lib_location yet.
    options(dss_location="C:\\Program Files (x86)\\HEC\\DSSVue\\")
    options(dss_jre_location="C:\\Program Files (x86)\\HEC\\DSSVue\\java32")
	options(dss_lib_location="C:\\Program Files (x86)\\HEC\\DSSVue\\lib32")
    # Java_home in 32-bit should point to Java Runtime envi. directory.
    Sys.setenv(JAVA_HOME="C:\\Program Files (x86)\\HEC\\DSSVue\\java")
}

@SwampThingPaul - I'm able to replicate your issue on my personal machine using 64-bit R 3.6.3 and the HEC libraries bundled with HEC-WAT. Unfortunately, I think this is an rJava issue. You might have better luck with an older version of R. I know it works in 3.4.

Thanks for check into this...I remember this package working a couple of months ago. I'll try a prior version of R and see how things work.

@SwampThingPaul - If you're still looking for a fix, I posted a new branch called "r36_rjava0.9-12fixes" that appears to work in 64-bit R 3.5 or 3.6 with the latest version of rJava (0.9-12) and the HEC-WAT as downloaded from the HEC website.

I had to add this to my .rprofile file (or just run before installing or loading dssrip):

if(R.Version()$arch=="x86_64"){
  # use 64-bit .jar and .dll
  options(dss_location="C:\\Program Files (x86)\\HEC\\HEC-WAT\\1.0\\HEC-WAT\\")
  options(dss_jre_location="C:\\Program Files (x86)\\HEC\\HEC-WAT\\1.0\\JavaRuntime64/")
  Sys.setenv(JAVA_HOME=options("dss_jre_location"))  # I think this should be: Sys.setenv(JAVA_HOME=""), but works anyway because not set for 64-bit.
}

i am getting error while loading the package.. i am attaching the error message below. can anyone help me to fix this?

Error: package or namespace load failed for ‘dssrip’:
.onLoad failed in loadNamespace() for 'dssrip', details:
call: file(con, "r")
error: cannot open the connection
In addition: Warning message:
In file(con, "r") :
cannot open file './config/jar_config.json': No such file or directory