Why not:

    sys.env.get("SPARK_HOME").orElse(sys.props.get("spark.home")).get

Or if you don't want to use `sys.props`:

    sys.env.get("SPARK_HOME").orElse(Option(System.getProperty("spark.home"))).get