Take care of SPARK_HOME is not defined

I made small modification to handle the case that SPARK_HOME is not defined.