diff --git a/R/pkg/R/client.R b/R/pkg/R/client.R index cf2e5ddeb7a9..3d2c2088f7a1 100644 --- a/R/pkg/R/client.R +++ b/R/pkg/R/client.R @@ -43,6 +43,20 @@ determineSparkSubmitBin <- function() { sparkSubmitBinName } +# R supports both file separator in the file path (Unix : / and Windows: \) irrespective of the operating system +# but when passing file path to Java or script program, it has to be converted according to operating system + +determinefileSeperator <- function() { + if (.Platform$OS.type == "unix") { + fileSeperator <- .Platform$file.sep + } else { +# .Platform$file.sep contains "/" for windows too +# http://www.inside-r.org/r-doc/base/file.path + fileSeperator <- "\\" + } + fileSeperator +} + generateSparkSubmitArgs <- function(args, sparkHome, jars, sparkSubmitOpts, packages) { if (jars != "") { jars <- paste("--jars", jars) @@ -57,9 +71,10 @@ generateSparkSubmitArgs <- function(args, sparkHome, jars, sparkSubmitOpts, pack } launchBackend <- function(args, sparkHome, jars, sparkSubmitOpts, packages) { - sparkSubmitBin <- determineSparkSubmitBin() + sparkSubmitBinName <- determineSparkSubmitBin() if (sparkHome != "") { - sparkSubmitBin <- file.path(sparkHome, "bin", sparkSubmitBinName) + fileSeperator <- determinefileSeperator() + sparkSubmitBin <- file.path(sparkHome, "bin", sparkSubmitBinName, fsep = fileSeperator) } else { sparkSubmitBin <- sparkSubmitBinName } diff --git a/R/pkg/R/sparkR.R b/R/pkg/R/sparkR.R index 8f81d5640c1d..1bff7df49bea 100644 --- a/R/pkg/R/sparkR.R +++ b/R/pkg/R/sparkR.R @@ -132,7 +132,7 @@ sparkR.init <- function( sparkHome = sparkHome, jars = jars, sparkSubmitOpts = Sys.getenv("SPARKR_SUBMIT_ARGS", "sparkr-shell"), - sparkPackages = sparkPackages) + packages = sparkPackages ) # wait atmost 100 seconds for JVM to launch wait <- 0.1 for (i in 1:25) {