#1137727 gpsd launched by gpsd.service does not pick up environment variables set by /etc/default/gpsd.

Package:
gpsd
Source:
gpsd
Description:
Global Positioning System - daemon
Submitter:
Charles Curley
Date:
2026-05-26 22:45:02 UTC
Severity:
normal
Tags:
#1137727#5
Date:
2026-05-26 22:43:26 UTC
From:
To:
Dear Maintainer,


   * What led up to the situation?

Trying to allow gpsd to listed for clients on interfaces in addition to localhost.

   * What exactly did you do (or not do) that was effective (or
     ineffective)?

The normal solution to this is to add -G to gpsd's command line. In Debian one does this by adding it to GPSD_OPTIONS in /et/default/gpsd. In addition, one must change the two ListenStream lines in gpsd.socket, and allow the gpsd port in one's firewall.

   * What was the outcome of this action?

Alas, inspection via "systemctl status gpsd.service" and some trials showed that this didn't work.

   * What outcome did you expect instead?

To run clients on other computers.


Solution 1

Per the documentation for systemd (https://www.freedesktop.org/software/systemd/man/latest/systemd.exec.html?__goaway_challenge=meta-refresh&__goaway_id=0b05803d66e99ff3865d62fa1b482943) one must use a PassEnvironment line to tell systemd to pass desired environment variables. So I added the following line to gpsd.service ("systemctl edit gpsd.service"):

PassEnvironment=GPSD_OPTIONS OPTIONS DEVICES

right after the EnvironmentFile line. That worked.

Solution 2

Another way to handle the issue is to edit the desired option right into the ExecStart line. That would suggest instead getting rid of the EnvironmentFile line and /etc/default/gpsd. That also works, but is less "the Debian way".

Thank you.