Try this:
\path{$SPARK_HOME/conf\iffalse$\fi}
The part inside \iffalse ... \fi is never executed but should fool your editor that the inline math is ending there.
Another option is to never use $ there in the first place. As \path redefines special characters to typeset them, some more verbosity is needed:
\def\dollar{^^d}
\expandafter\path\expandafter{\dollar SPARK_HOME/conf}
^^d is a TeX variant to input $. So we define a macro that expands to this character but has to take care to expand the macro before \path starts processing its argument, hence the \expandafters.
Another option does not work for the ShareLatex.
$will allegedly satisfy the syntax highlighter. Kile tries to be clever and ignores the commented code, so I have to think of something else to avoid an all-magenta document. – cfr Mar 26 '17 at 03:49