I'm not able to install packages from source to R in Windows, and I have not been able to find anybody else with this error here and elsewhere online.
I'm working on a PC that is not my personal PC, and I'm able to install packages to only two different directories. The file path of each of these drives start with two forward slashes ("//"), and only work with these forwards slashes or work if the forward slashes are replaced by backward slashes ("\\").
If I try to install to a directory "//drive/filepath" for (for example) H2O:
install.packages("h2o", type="source", repos="http://h2o-release.s3.amazonaws.com/h2o/rel-xu/1/R", lib = "//drive/filepath")
R downloads the .tar.gz source file fine, however when it tries to install it I get the error:
* installing *source* package 'h2o' ...
** R
** demo
** inst
Warning in file.create(to[okay]) :
cannot create file '\drive/filepath/h2o/branch.txt', reason 'No such file or directory'
(THEN THE SAME WARNING FOR MULTIPLE OTHER FILES IT TRIES TO INSTALL TO THE SAME PATH)
** byte-compile and prepare package for lazy loading
Warning in file(con, "r") :
cannot open file '\\drive/filepath/h2o/branch.txt': No such file or directory
Error in file(con, "r") : cannot open the connection
Error : unable to load R code in package 'h2o'
ERROR: lazy loading failed for package 'h2o'
* removing '\\drive/filepath/h2o'
In R CMD INSTALL
Warning in install.packages :
installation of package ‘h2o’ had non-zero exit status
So what it looks like R is doing is converting the double forward slash ("//") at the start of the file path into a double backwards slash ("\"). R then recognises ("\") in the string as the escape character for a single back slash ("\"), so the string where it tries to install the files becomes simply "\drive/filepath", which doesn't work. That's what I think is happening, anyway.
I tried instead to use four forward slashes, thinking it would change this to four backwards slashes, and thus it would look for a drive with two backwards slashes:
install.packages("h2o", type="source", repos="http://h2o-release.s3.amazonaws.com/h2o/rel-xu/1/R", lib = "////drive/filepath")
However it tried to find the file path before converting the forward slashes into backwards slashes, and obviously didn't recognise it as an existing file path:
Warning in install.packages :
'lib = "////drive/directory"' is not writable
Error in install.packages : unable to install packages
I also tried the command using four and eight backwards slashes, with the same result, ie. the two commands below give the same error as above:
install.packages("h2o", type="source", repos="http://h2o-release.s3.amazonaws.com/h2o/rel-xu/1/R", lib = "\\\\drive/filepath")
install.packages("h2o", type="source", repos="http://h2o-release.s3.amazonaws.com/h2o/rel-xu/1/R", lib = "\\\\\\\\drive/filepath")
Is there any way for me to fix this, please? As I said, I don't own this PC (it belongs to somebody else) so creating/changing drives is not an option, neither is downloading other software.
Note: I can install from .zip files fine.