Only certain environment variables are set in systemd

systemd

I have a systemd file starting a JupyterHub:

[Unit]
Description=Jupyterhub

[Service]
User=root
Environment="PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/opt/spark/bin:/opt/hadoop/bin"
Environment="HADOOP_HOME=/opt/hadoop"
Environment="JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64"
ExecStart=/usr/local/bin/jupyterhub -f /opt/jupyter/jupyterhub_config.py

[Install]
WantedBy=multi-user.target

However, only the PATH variable is set, the settings for HADOOP_HOME and JAVA_HOME are ignored.

What am I missing?

Best Answer

Believe it or not, it might be your use of quotes. Systemd is that rare beast that can handle multiple equal signs without getting horribly confused (in the ways you'd expect).

[Service]
Environment=HADOOP_HOME=/opt/hadoop
Environment=JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64

It doesn't look like it'll work, but I have units on my system written that way and they work.