Skip to content

Commit ea58e52

Browse files
committed
[SPARK-32434][CORE][FOLLOW-UP] Fix load-spark-env.cmd to be able to run in Windows properly
### What changes were proposed in this pull request? This PR is basically a followup of SPARK-26132 and SPARK-32434. You can't define an environment variable within an-if to use it within the block. See also https://superuser.com/questions/78496/variables-in-batch-file-not-being-set-when-inside-if ### Why are the changes needed? For Windows users to use Spark and fix the build in AppVeyor. ### Does this PR introduce _any_ user-facing change? No, it's only in unreleased branches. ### How was this patch tested? Manually tested on a local Windows machine, and AppVeyor build at HyukjinKwon#13. See https://ci.appveyor.com/project/HyukjinKwon/spark/builds/34316409 Closes #29254 from HyukjinKwon/SPARK-32434. Authored-by: HyukjinKwon <gurwls223@apache.org> Signed-off-by: HyukjinKwon <gurwls223@apache.org>
1 parent 998086c commit ea58e52

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

bin/load-spark-env.cmd

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ rem spark-env.cmd is loaded from SPARK_CONF_DIR if set, or within the current di
2222
rem conf\ subdirectory.
2323

2424
set SPARK_ENV_CMD=spark-env.cmd
25-
if [%SPARK_ENV_LOADED%] == [] (
25+
if not defined SPARK_ENV_LOADED (
2626
set SPARK_ENV_LOADED=1
2727

2828
if [%SPARK_CONF_DIR%] == [] (
@@ -37,18 +37,19 @@ if [%SPARK_ENV_LOADED%] == [] (
3737

3838
rem Setting SPARK_SCALA_VERSION if not already set.
3939

40-
if [%SPARK_SCALA_VERSION%] == [] (
41-
set SCALA_VERSION_1=2.13
42-
set SCALA_VERSION_2=2.12
40+
set SCALA_VERSION_1=2.13
41+
set SCALA_VERSION_2=2.12
4342

44-
set ASSEMBLY_DIR1=%SPARK_HOME%\assembly\target\scala-%SCALA_VERSION_1%
45-
set ASSEMBLY_DIR2=%SPARK_HOME%\assembly\target\scala-%SCALA_VERSION_2%
46-
set ENV_VARIABLE_DOC=https://spark.apache.org/docs/latest/configuration.html#environment-variables
43+
set ASSEMBLY_DIR1=%SPARK_HOME%\assembly\target\scala-%SCALA_VERSION_1%
44+
set ASSEMBLY_DIR2=%SPARK_HOME%\assembly\target\scala-%SCALA_VERSION_2%
45+
set ENV_VARIABLE_DOC=https://spark.apache.org/docs/latest/configuration.html#environment-variables
46+
47+
if not defined SPARK_SCALA_VERSION (
4748
if exist %ASSEMBLY_DIR2% if exist %ASSEMBLY_DIR1% (
48-
echo "Presence of build for multiple Scala versions detected (%ASSEMBLY_DIR1% and %ASSEMBLY_DIR2%)."
49-
echo "Remove one of them or, set SPARK_SCALA_VERSION=%SCALA_VERSION_1% in %SPARK_ENV_CMD%."
50-
echo "Visit %ENV_VARIABLE_DOC% for more details about setting environment variables in spark-env.cmd."
51-
echo "Either clean one of them or, set SPARK_SCALA_VERSION in spark-env.cmd."
49+
echo Presence of build for multiple Scala versions detected ^(%ASSEMBLY_DIR1% and %ASSEMBLY_DIR2%^).
50+
echo Remove one of them or, set SPARK_SCALA_VERSION=%SCALA_VERSION_1% in spark-env.cmd.
51+
echo Visit %ENV_VARIABLE_DOC% for more details about setting environment variables in spark-env.cmd.
52+
echo Either clean one of them or, set SPARK_SCALA_VERSION in spark-env.cmd.
5253
exit 1
5354
)
5455
if exist %ASSEMBLY_DIR1% (

0 commit comments

Comments
 (0)