Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Installation under Windows #14

Closed
aoles opened this issue Sep 28, 2018 · 22 comments · Fixed by #19
Closed

Installation under Windows #14

aoles opened this issue Sep 28, 2018 · 22 comments · Fixed by #19

Comments

@aoles
Copy link
Owner

aoles commented Sep 28, 2018

Hi, Andrzej!

I am stuck while trying to install Rbioformats in Windows 10. Rtools and devtools are installed, packages can be compile from source. rJava compiled fine and loads properly. However, when running I get

biocLite("aoles/RBioFormats")

I get the following output:

BioC_mirror: https://bioconductor.org
Using Bioconductor 3.7 (BiocInstaller 1.30.0), R 3.5.1 (2018-07-02).
Installing github package(s) ‘aoles/RBioFormats’
Downloading GitHub repo aoles/RBioFormats@master
Installing package into ‘C:/Users/Geo/Documents/R/win-library/3.5’
(as ‘lib’ is unspecified)

  • installing source package 'RBioFormats' ...
    ** R
    ** inst
    ** byte-compile and prepare package for lazy loading
    ** help
    *** installing help indices
    converting help for package 'RBioFormats'
    finding HTML links ... done
    AnnotatedImage-class html
    finding level-2 HTML links ... done

    AnnotatedImageList-class html
    BioFormats.version html
    FormatTools html
    ImageMetadata-class html
    RBioFormats html
    checkJavaMemory html
    dimorder html
    metadata html
    metadataAccessors html
    mockFile html
    read.image html
    read.metadata html
    read.omexml html
    seriesCount html
    write.image html
    ** building package indices
    ** installing vignettes
    ** testing if installed package can be loaded
    trying URL 'https://downloads.openmicroscopy.org/bio-formats/5.9.1/artifacts/bioformats_package.jar'
    Content type 'application/x-java-archive' length 31779356 bytes (30.3 MB)
    ==================================================
    downloaded 30.3 MB

Error: package or namespace load failed for 'RBioFormats':
.onLoad failed in loadNamespace() for 'RBioFormats', details:
call: .jfield("loci/formats/FormatTools", "S", "VERSION")
error: cannot find class loci/formats/FormatTools
Error: loading failed
Execution halted
ERROR: loading failed

  • removing 'C:/Users/Geo/Documents/R/win-library/3.5/RBioFormats'
    In R CMD INSTALL
    Warning message:
    In i.p(...) :
    installation of package ‘C:/Users/Geo/AppData/Local/Temp/RtmpU7bsbM/remotes13fc5a4431eb/aoles-RBioFormats-9d104f6’ had non-zero exit status

Do you have an idea what might go wrong?

Many thanks in advance,

Geo

From: "Andrzej K. Oleś" [email protected]
Reply-To: aoles/RBioFormats [email protected]
Date: Sunday, May 13, 2018 at 1:03 PM
To: aoles/RBioFormats [email protected]
Cc: Geo Vogler [email protected], State change [email protected]
Subject: Re: [aoles/RBioFormats] meta data is different between ImageJ and RBioformats (#11)

Hi Geo,

thank you for reaching out and for reporting the disappointing performance of read.metadata. I will look int this, I've opened a dedicated issue#12 in order to better keep track of it.

Best,
Andrzej


You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub#11 (comment), or mute the threadhttps://github.com/notifications/unsubscribe-auth/AaGUenMsW-xwAM96YwOFxAUFg_aRCrKjks5tyJF3gaJpZM4Sppuu.

Originally posted by @GrauKatze in #11 (comment)

@gvogler
Copy link

gvogler commented Oct 31, 2018

Hi, Andrzej!

Any news on this issue? Or pointers of what I could try to help troubleshooting?

-Geo

@Wang-Hsiang-Sheng
Copy link

I also face the same problem in windows 10 on my own computer and work place.
Is this issue specific to windows 10 or other OS also face the same problem?

@Wang-Hsiang-Sheng
Copy link

I think the problem is due to java class path isn't set properly when .jfield("loci/formats/FormatTools", "S", "VERSION") is called. I downloaded "bioformats_package.jar" first and put it in one folder, then entered the utils.R file and change some code from:
"BioFormats.version = function() .jfield("loci/formats/FormatTools", "S", "VERSION")"
to:
"BioFormats.version = function() {
library(rJava)
.jinit()
.jaddClassPath(location of "bioformats_package.jar" just downloaded)
.jfield("loci/formats/FormatTools", "S", "VERSION")
}"
then install this package again show no problem on my Windows
and RBioFormats can also be loaded properly after installation

@gvogler
Copy link

gvogler commented Jan 7, 2019

Doesn't seem to work in my installation - it still downloads the file and fails with call: .jfield.
Setting CLASSPATH in the Windows Environment should do the trick as well and doesn't.

@manerotoni
Copy link

Same issue here (R 3.5.3, Windows10). I don't understand where do I find the "utils.R" file so to try @Wang-Hsiang-Sheng suggestion.

@manerotoni
Copy link

manerotoni commented Apr 2, 2019

What worked for me.
download bioformats
Clone this repo
Change the file RBioformats/R/utils.R as described by @Wang-Hsiang-Sheng
Start R from the main path of the cloned directory
run devtools::build()
in my case it first failed twice because I had to install 2 additional packages
BiocStyle (biocLite('BiocStyle')) and
XML install.packages('XML')
after installing the 2 packages devtools:build() was successful and the package seems to work.
In fact at library('RBioFormats') it automatically download again a bioformat_package.jar.

@oodegard
Copy link

oodegard commented May 2, 2019

The @manerotoni method worked for me, but I would like to add that you ofcause have to install the library afterwards from the filepath that was created with devtools::build().
What I did was:

  1. Download bioformats to my .libPaths() path
  2. Clone repo to my "C:/R/" folder from git bash
git clone https://github.com/aoles/RBioFormats.git
  1. Change the file RBioformats/R/utils.R as described by @Wang-Hsiang-Sheng
BioFormats.version = function() .jfield("loci/formats/FormatTools", "S", "VERSION")"
to:
"BioFormats.version = function() {
library(rJava)
.jinit()
.jaddClassPath(location of "bioformats_package.jar" just downloaded) ## in my case ".jaddClassPath("C:/R/Library/bioformats/bioformats_package.jar")"
.jfield("loci/formats/FormatTools", "S", "VERSION")
}
  1. Set the working directory to the cloned RBioFormats directory
  2. Build RBioFormats
run devtools::build() # you may need to install additional packages
# [1] "C:/R/RBioFormats_0.0.54.tar.gz"
  1. Install RBioFormats from the newly built
install.packages("C:/R/RBioFormats_0.0.54.tar.gz", repos = NULL, type = "source")

@gvogler
Copy link

gvogler commented May 3, 2019

This works perfect. Those last steps were not clear to me (location of library/bioformats vs. repo clone) before.

@gvogler
Copy link

gvogler commented May 28, 2019

I just noticed that now it downloads the bioformats package everytime the library is loaded. Do you see this as well?

@aoles
Copy link
Owner Author

aoles commented May 28, 2019

Hi guys,

joining the party late - let me apologize for this! First off all, many thanks to all of you involved in debugging this, I really appreciate your commitment.

Normally JVM initialization should be performed through .jpackage(), see the details in ?.jinit. I'm not entirely sure what the problem here could be as this is already called before BioFormats.version(), I will need to look into it.

For now could you maybe verify whether disabling the package startup message resolves the issue? Please try running the modified version through

devtools::install_github("aoles/RBioFormats@debug").

Looking forward to your feedback!

Cheers,
Andrzej

@gvogler
Copy link

gvogler commented May 28, 2019

Nice - this installed like a charm on a vanilla Windows 7, RStudio, R3.5.3 64bit.

However, it still downloads the bioformats package from openmicroscopy.org whenever the RBioFormats library is loaded.

@aoles
Copy link
Owner Author

aoles commented May 28, 2019

Thanks @GrauKatze for getting back to me so quickly!

I've just modified the test branch to print some debug messages, would you mind reinstalling the package once again and paste here the output you get when you load the package?

Cheers,
Andrzej

@gvogler
Copy link

gvogler commented May 28, 2019

library(RBioFormats)
Loading required package: rJava
MD5 local: 3055c5e3c8378a619b73ebe2e83c8929
MD5 remote: 6e8fa3e3919cb8408a23ca73b38d33d5
trying URL 'https://downloads.openmicroscopy.org/bio-formats/6.0.0/artifacts/bioformats_package.jar'
Content type 'application/x-java-archive' length 35214253 bytes (33.6 MB)
downloaded 33.6 MB

@aoles
Copy link
Owner Author

aoles commented May 28, 2019

Awesome, thanks! So the problem comes from the fact that the checksum of your local library copy does not match the remote one, weird.

Do you consistently get the same value 3055c5e3c8378a619b73ebe2e83c8929 when you reload the package?

@gvogler
Copy link

gvogler commented May 28, 2019

Yes, it is the identical message each time.

@aoles
Copy link
Owner Author

aoles commented May 28, 2019

Thanks for verifying! Might be related to the following comment in ?tools::md5sum.

On Windows all files are read in binary mode (as the md5sum utilities there do): on other OSes the files are read in the default mode (almost always text mode where there is more than one).

Could you maybe check what value you get when you manually download the file https://downloads.openmicroscopy.org/bio-formats/6.0.0/artifacts/bioformats_package.jar and run tools::md5sum() on it?

@gvogler
Copy link

gvogler commented May 28, 2019

tools::md5sum("bioformats.jar") on the downloaded file returns the remote value (MD5 remote: 6e8fa3e3919cb8408a23ca73b38d33d5)

@aoles
Copy link
Owner Author

aoles commented May 29, 2019

Great, thanks a lot!

So I guess we can rule out tools::md5sum() then. However, there might be a problem with utils::download.file(), in particular the default file write mode. In order to verify this, would you mind pasting the output of running the following code snippet on your system?

Cheers,
Andrzej

url <- "https://downloads.openmicroscopy.org/bio-formats/6.0.0/artifacts/bioformats_package.jar"

for (m in c("w", "wb")) {
	f <- tempfile("", , ".jar")
	utils::download.file(url, f, mode = m, quiet = TRUE)
	message(tools::md5sum(f))
}

@gvogler
Copy link

gvogler commented May 29, 2019

I ran this 2x, with different results:

> url <- "https://downloads.openmicroscopy.org/bio-formats/6.0.0/artifacts/bioformats_package.jar"
> 
> for (mode in c("w", "wb")) {
+     f <- tempfile("", , ".jar")
+     utils::download.file(url, f, quiet=TRUE)
+     message(tools::md5sum(f))
+ }
3055c5e3c8378a619b73ebe2e83c8929
3055c5e3c8378a619b73ebe2e83c8929
> url <- "https://downloads.openmicroscopy.org/bio-formats/6.0.0/artifacts/bioformats_package.jar"
> 
> for (m in c("w", "wb")) {
+     f <- tempfile("", , ".jar")
+     utils::download.file(url, f, mode = m, quiet = TRUE)
+     message(tools::md5sum(f))
+ }
3055c5e3c8378a619b73ebe2e83c8929
6e8fa3e3919cb8408a23ca73b38d33d5

@aoles
Copy link
Owner Author

aoles commented May 29, 2019

Great, thanks a lot!

So the problem with reoccurring downloads was caused by the default mode = "w", I've modified the debug branch to use mode = "wb".

Additionally, I've updated the way how the library version is being resolved during startup.

Looking forward to your feedback!

Cheers,
Andrzej

@gvogler
Copy link

gvogler commented May 29, 2019

This looks good (on Windows 10 and macOS)!

> library(RBioFormats)
Loading required package: rJava
MD5 local:  6e8fa3e3919cb8408a23ca73b38d33d5
MD5 remote: 6e8fa3e3919cb8408a23ca73b38d33d5
BioFormats library version 6.0.0

@aoles
Copy link
Owner Author

aoles commented May 29, 2019

Awesome, glad to hear that!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants