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

Error for h2o_start() without java installed #43

Closed
hfrick opened this issue Nov 4, 2022 · 6 comments
Closed

Error for h2o_start() without java installed #43

hfrick opened this issue Nov 4, 2022 · 6 comments

Comments

@hfrick
Copy link
Member

hfrick commented Nov 4, 2022

When I run h2o_start() without things installed/configured correctly, I do get

> h2o_start()
The operation couldn’t be completed. Unable to locate a Java Runtime.
Please visit http://www.java.com for information on installing Java.

but then it just hangs there. It would be nice if that threw an error instead.

@qiushiyan
Copy link
Collaborator

qiushiyan commented Nov 5, 2022

Thanks @hfrick for reporting this. I didn't see this error message after searching the h2o codebase. I found this function .h2o.checkJava to be used for determining java installation though, which relies on Sys.getenv('JAVA_HOME') and Sys.which('java'). After I cleaned PATH I got the error

withr::with_path(
  getwd(), 
  {
    print(c(Sys.which("java"), Sys.getenv("JAVA_HOME")))
    agua::h2o_start()
  }, 
  action = "replace"
)
#> java      
#>   ""   ""
#> Registered S3 method overwritten by 'agua':
#>   method        from     
#>   tidy.workflow workflows
#> Error in .h2o.checkJava(): Cannot find Java. Please install the latest JRE from
#> https://www.oracle.com/technetwork/java/javase/downloads/index.html

Created on 2022-11-05 with reprex v2.0.2

@hfrick
Copy link
Member Author

hfrick commented Nov 7, 2022

Ah, thanks for this! So I do have java installed but I do not have JAVA_HOMEset. I put your example in a reprex and with the working directory as the path, I get the same as you. If I don't set that, as in the first part of the reprex below, it also errors but it only does so eventually. When I ran that first part interactively, I've never been patient enough to wait...

print(c(Sys.which("java"), Sys.getenv("JAVA_HOME")))
#>            java                 
#> "/usr/bin/java"              ""
agua::h2o_start()
#> Registered S3 method overwritten by 'agua':
#>   method        from     
#>   tidy.workflow workflows
#> Warning in system2(command, "-version", stdout = TRUE, stderr = TRUE): running
#> command ''/usr/bin/java' -version 2>&1' had status 1
#> Error in h2o::h2o.init(): H2O failed to start, stopping execution.

withr::with_path(
  getwd(), 
  {
    print(c(Sys.which("java"), Sys.getenv("JAVA_HOME")))
    agua::h2o_start()
  }, 
  action = "replace"
)
#> java      
#>   ""   ""
#> Error in .h2o.checkJava(): Cannot find Java. Please install the latest JRE from
#> https://www.oracle.com/technetwork/java/javase/downloads/index.html

Created on 2022-11-07 with reprex v2.0.2

@qiushiyan
Copy link
Collaborator

What is the output if you run /usr/bin/java -version from the command line? Seems this fails to locate java's version. The hanging is caused by https://github.com/h2oai/h2o-3/blob/master/h2o-r/h2o-package/R/connection.R#L217-L223 which tries to wait for 60 seconds before connection is established, agua could probabably do an early stop or add messages if previous commands fail.

@hfrick
Copy link
Member Author

hfrick commented Nov 9, 2022

yup, looks like it can't locate it

 % /usr/bin/java -version
The operation couldn’t be completed. Unable to locate a Java Runtime.
Please visit http://www.java.com for information on installing Java.

an alternative to failing earlier than 60 seconds could also be telling the user that this step can take up to 60 seconds

@qiushiyan
Copy link
Collaborator

fixed by 9922d26

@github-actions
Copy link

This issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with a reprex: https://reprex.tidyverse.org) and link to this issue.

@github-actions github-actions bot locked and limited conversation to collaborators Jun 18, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants