Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error while using h2o.init in R

Tags:

r

h2o

This is the error message:

   > h2o.init()
Error in dirname(path) : path too long
In addition: There were 12 warnings (use warnings() to see them)

This is one of the warning messages (the others are similar):

> warnings()
    Warning messages:
    1: In normalizePath(path.expand(path), winslash, mustWork) :
      path[1]="\\FILE-EM1-06/USERDATA2$/john134/My Documents/./../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../..": The filename or extension is too long

Any idea how to work around this error?

Thanks

like image 796
John McClain Avatar asked Mar 23 '17 10:03

John McClain


3 Answers

It seems that Windows path string is limited to (maybe) 256 length. Usually, setting a the path setwd(shorterExistingWorkDir) works and should address your issue.

like image 58
Giorgio Spedicato Avatar answered Nov 04 '22 14:11

Giorgio Spedicato


I struggled with this issue quite a bit, including upgrading.

Most folks are assuming that you've literally just set an incredibly long path. I don't think this is the case (it wasn't for me, at least). It's that the PATH may be set on a network drive or other device where the underlying mapped paths are more complicated.

A related thread is here on the H2O forum:

Main issue is the user had a Windows drive that did not conform to the norm, i.e., "C://", etc. Instead, the user had a network drive (DTCHYB-AZPX015/). This caused issues in the search for a config file as there was no "root" (In this case, "root" is reaching your Win drive). Since there was no "root", the path to search kept expanding until it caused R to error out with the above exception.

The fix is to NOT search for a config when h2o.init() is called. Rather, only search for a config if a user asks to do so. My proposal is to add a new field to h2o.init()called ignore_config. This field will be set to TRUE by default.

like image 1
Hack-R Avatar answered Nov 04 '22 14:11

Hack-R


When calling h2o.init() the R environment signal the launching of h2o application (actually a web server) in the backend which was installed when you install H2O package into R. The local runtime environment uses the full path of the location where H2O jar file is located. Because the packages is installed deep inside the nested folders in your file system it cross the valid limit of OS path 256 character length and fails to launch the backend H2O server and you see this error. In your case you are using external path so adds up more characters in the path to make the problem worse..

For example the h2o.jar is located in my OSX machine as below:

/Library/Frameworks/R.framework/Resources/library/h2o  <-- H2O package Path
/Library/Frameworks/R.framework/Resources/library/h2o/java/h2o.jar <-- Jar Path

As you are using Windows, what you need is to find ways to reduce this path to OS limit and it will work.

The other solution is to run h2o.jar separately and then just use R to connect to H2O cluster. The steps are as below:

  1. Download H2O 3.10.4.2 and unzip to a folder close to root so you do not hit 265 char limit again. Also install 3.10.4.2 R Package. (Try to keep the same version)
  2. Run H2O > java -jar h2o.jar
  3. From RStudio console try > h2o.init()

So if there is already H2O cluster running the h2o.init() will connect to a running H2O cluster instead to start one and you will by pass above problem.

If you hit any problem write here and we will help you.

like image 1
AvkashChauhan Avatar answered Nov 04 '22 14:11

AvkashChauhan