Skip to content

Commit 49f3882

Browse files
tsudukimsrowen
authored andcommitted
[SPARK-6673] spark-shell.cmd can't start in Windows even when spark was built
added equivalent script to load-spark-env.sh Author: Masayoshi TSUZUKI <[email protected]> Closes apache#5328 from tsudukim/feature/SPARK-6673 and squashes the following commits: aaefb19 [Masayoshi TSUZUKI] removed dust. be3405e [Masayoshi TSUZUKI] [SPARK-6673] spark-shell.cmd can't start in Windows even when spark was built
1 parent 0b5d028 commit 49f3882

File tree

4 files changed

+62
-6
lines changed

4 files changed

+62
-6
lines changed

bin/load-spark-env.cmd

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
@echo off
2+
3+
rem
4+
rem Licensed to the Apache Software Foundation (ASF) under one or more
5+
rem contributor license agreements. See the NOTICE file distributed with
6+
rem this work for additional information regarding copyright ownership.
7+
rem The ASF licenses this file to You under the Apache License, Version 2.0
8+
rem (the "License"); you may not use this file except in compliance with
9+
rem the License. You may obtain a copy of the License at
10+
rem
11+
rem http://www.apache.org/licenses/LICENSE-2.0
12+
rem
13+
rem Unless required by applicable law or agreed to in writing, software
14+
rem distributed under the License is distributed on an "AS IS" BASIS,
15+
rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
rem See the License for the specific language governing permissions and
17+
rem limitations under the License.
18+
rem
19+
20+
rem This script loads spark-env.cmd if it exists, and ensures it is only loaded once.
21+
rem spark-env.cmd is loaded from SPARK_CONF_DIR if set, or within the current directory's
22+
rem conf/ subdirectory.
23+
24+
if [%SPARK_ENV_LOADED%] == [] (
25+
set SPARK_ENV_LOADED=1
26+
27+
if not [%SPARK_CONF_DIR%] == [] (
28+
set user_conf_dir=%SPARK_CONF_DIR%
29+
) else (
30+
set user_conf_dir=%~dp0..\..\conf
31+
)
32+
33+
call :LoadSparkEnv
34+
)
35+
36+
rem Setting SPARK_SCALA_VERSION if not already set.
37+
38+
set ASSEMBLY_DIR2=%SPARK_HOME%/assembly/target/scala-2.11
39+
set ASSEMBLY_DIR1=%SPARK_HOME%/assembly/target/scala-2.10
40+
41+
if [%SPARK_SCALA_VERSION%] == [] (
42+
43+
if exist %ASSEMBLY_DIR2% if exist %ASSEMBLY_DIR1% (
44+
echo "Presence of build for both scala versions(SCALA 2.10 and SCALA 2.11) detected."
45+
echo "Either clean one of them or, set SPARK_SCALA_VERSION=2.11 in spark-env.cmd."
46+
exit 1
47+
)
48+
if exist %ASSEMBLY_DIR2% (
49+
set SPARK_SCALA_VERSION=2.11
50+
) else (
51+
set SPARK_SCALA_VERSION=2.10
52+
)
53+
)
54+
exit /b 0
55+
56+
:LoadSparkEnv
57+
if exist "%user_conf_dir%\spark-env.cmd" (
58+
call "%user_conf_dir%\spark-env.cmd"
59+
)

bin/pyspark2.cmd

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ rem
2020
rem Figure out where the Spark framework is installed
2121
set SPARK_HOME=%~dp0..
2222

23-
rem Load environment variables from conf\spark-env.cmd, if it exists
24-
if exist "%SPARK_HOME%\conf\spark-env.cmd" call "%SPARK_HOME%\conf\spark-env.cmd"
23+
call %SPARK_HOME%\bin\load-spark-env.cmd
2524

2625
rem Figure out which Python to use.
2726
if "x%PYSPARK_DRIVER_PYTHON%"=="x" (

bin/run-example2.cmd

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@ set FWDIR=%~dp0..\
2525
rem Export this as SPARK_HOME
2626
set SPARK_HOME=%FWDIR%
2727

28-
rem Load environment variables from conf\spark-env.cmd, if it exists
29-
if exist "%FWDIR%conf\spark-env.cmd" call "%FWDIR%conf\spark-env.cmd"
28+
call %SPARK_HOME%\bin\load-spark-env.cmd
3029

3130
rem Test that an argument was given
3231
if not "x%1"=="x" goto arg_given

bin/spark-class2.cmd

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ rem
2020
rem Figure out where the Spark framework is installed
2121
set SPARK_HOME=%~dp0..
2222

23-
rem Load environment variables from conf\spark-env.cmd, if it exists
24-
if exist "%SPARK_HOME%\conf\spark-env.cmd" call "%SPARK_HOME%\conf\spark-env.cmd"
23+
call %SPARK_HOME%\bin\load-spark-env.cmd
2524

2625
rem Test that an argument was given
2726
if "x%1"=="x" (

0 commit comments

Comments
 (0)