Github user HyukjinKwon commented on a diff in the pull request: https://github.com/apache/spark/pull/16305#discussion_r92912156 --- Diff: core/src/main/scala/org/apache/spark/deploy/RPackageUtils.scala --- @@ -231,8 +236,10 @@ private[deploy] object RPackageUtils extends Logging { val zipOutputStream = new ZipOutputStream(new FileOutputStream(zipFile, false)) try { filesToBundle.foreach { file => - // get the relative paths for proper naming in the zip file - val relPath = file.getAbsolutePath.replaceFirst(dir.getAbsolutePath, "") + // Get the relative paths for proper naming in the zip file. Note that + // the separator should always be / for according to ZIP specification. + // `relPath` here should be, for example, "/packageTest/def.R" or "/test.R". + val relPath = file.toURI.toString.replaceFirst(dir.toURI.toString.stripSuffix("/"), "") --- End diff -- For example, **Before** - Windows ```scala val a = file.getAbsolutePath // "C:\...\tmp\1481863447985-0" val b = dir.getAbsolutePath // "C:\...\tmp\1481863447985-0\test.R" a.replaceFirst(b, "") // java.util.regex.PatternSyntaxException: Unknown character property name {r} near index 4 ``` ``` [info] java.util.regex.PatternSyntaxException: Unknown character property name {r} near index 4 [info] C:\projects\spark\target\tmp\1481863447985-0 [info] ^ [info] at java.util.regex.Pattern.error(Pattern.java:1955) [info] at java.util.regex.Pattern.charPropertyNodeFor(Pattern.java:2781) [info] at java.util.regex.Pattern.family(Pattern.java:2736) [info] at java.util.regex.Pattern.sequence(Pattern.java:2076) [info] at java.util.regex.Pattern.expr(Pattern.java:1996) [info] at java.util.regex.Pattern.compile(Pattern.java:1696) [info] at java.util.regex.Pattern.<init>(Pattern.java:1351) [info] at java.util.regex.Pattern.compile(Pattern.java:1028) [info] at java.lang.String.replaceFirst(String.java:2178) [info] at org.apache.spark.deploy.RPackageUtils$$anonfun$zipRLibraries$2.apply(RPackageUtils.scala:235) ``` - Linux/Mac ```scala val a = file.getAbsolutePath // "/var/.../T/1481938681657-0/test.R" val b = dir.getAbsolutePath // "/var/.../T/1481938681657-0" a.replaceFirst(b, "") // "/test.R" ``` **After** - Windows ```scala val a = file.toURI.toString // "file:/C:/.../tmp/1481863447985-0/test.R" val b = dir.toURI.toString // "file:/C:/.../tmp/1481863447985-0/" a.replaceFirst(b.stripSuffix("/"), "") // "/test.R" ``` - Linux/Mac ```scala val a = file.toURI.toString // "file:/var/.../T/1481938681657-0/test.R" val b = dir.toURI.toString // "file:/var/.../T/1481938681657-0/" a.replaceFirst(b.stripSuffix("/"), "") // "/test.R" ```
--- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. --- --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org