Skip to content

Commit 359cd59

Browse files
committed
[SPARK-1919] Fix Windows spark-shell --jars
We were trying to add `file:/C:/path/to/my.jar` to the class path. We should add `C:/path/to/my.jar` instead. Tested on Windows 8.1. Author: Andrew Or <[email protected]> Closes #2211 from andrewor14/windows-shell-jars and squashes the following commits: 262c6a2 [Andrew Or] Oops... Add the new code to the correct place 0d5a0c1 [Andrew Or] Format jar path only for adding to shell classpath 42bd626 [Andrew Or] Remove unnecessary code 0049f1b [Andrew Or] Remove embarrassing log messages b1755a0 [Andrew Or] Format jar paths properly before adding them to the classpath
1 parent 23fd3e8 commit 359cd59

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

repl/src/main/scala/org/apache/spark/repl/SparkILoop.scala

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import scala.tools.nsc.interpreter._
1414
import scala.tools.nsc.interpreter.{ Results => IR }
1515
import Predef.{ println => _, _ }
1616
import java.io.{ BufferedReader, FileReader }
17+
import java.net.URI
1718
import java.util.concurrent.locks.ReentrantLock
1819
import scala.sys.process.Process
1920
import scala.tools.nsc.interpreter.session._
@@ -186,8 +187,16 @@ class SparkILoop(in0: Option[BufferedReader], protected val out: JPrintWriter,
186187
require(settings != null)
187188

188189
if (addedClasspath != "") settings.classpath.append(addedClasspath)
190+
val addedJars =
191+
if (Utils.isWindows) {
192+
// Strip any URI scheme prefix so we can add the correct path to the classpath
193+
// e.g. file:/C:/my/path.jar -> C:/my/path.jar
194+
SparkILoop.getAddedJars.map { jar => new URI(jar).getPath.stripPrefix("/") }
195+
} else {
196+
SparkILoop.getAddedJars
197+
}
189198
// work around for Scala bug
190-
val totalClassPath = SparkILoop.getAddedJars.foldLeft(
199+
val totalClassPath = addedJars.foldLeft(
191200
settings.classpath.value)((l, r) => ClassPath.join(l, r))
192201
this.settings.classpath.value = totalClassPath
193202

0 commit comments

Comments
 (0)