Skip to content

install-langtechdepot.sh: systemd unit breaks if $HOME contains a space #9

Description

@dhigby

client/install-langtechdepot.sh writes the systemd unit with $BIN unquoted:

ExecStart=$BIN serve --no-browser --home "$CONFIG_DIR"

If $HOME contains a space, the rendered unit is:

ExecStart=/home/field user/.local/bin/syncthing serve --no-browser --home "/home/field user/.local/state/langtechdepot"

systemd reads that as the executable /home/field with user/.local/bin/syncthing as its first argument, so the service never starts. The --home value is quoted and survives; only the binary path is exposed.

Impact: low. Spaces in Linux home directories are rare. It becomes material if we do #8, because Mac home directories routinely contain them ("/Users/First Last"), so this is worth fixing before any Mac port rather than after.

Fix, and why I didn't just make it

Quoting the first token is valid — systemd's config_parse_exec() extracts it with extract_first_word_and_warn(…, EXTRACT_UNQUOTE|EXTRACT_CUNESCAPE, …), i.e. the executable path is unquoted the same way the arguments are, after any -/@/:/+ prefix characters are consumed:

ExecStart="$BIN" serve --no-browser --home "$CONFIG_DIR"

I left it alone because there is no systemd on the authoring machine to test against, and a malformed ExecStart would break every Linux install rather than only the rare one this fixes. That trade seemed worth a second pair of eyes rather than a blind edit. Whoever has a Linux box can confirm it in one go:

systemctl --user cat langtechdepot.service
systemctl --user status langtechdepot.service

One caveat if you do change it: EXTRACT_CUNESCAPE means systemd also C-unescapes the token, so a backslash in the path would need doubling. Irrelevant for real home directories, but it is the reason quoting alone isn't a general-purpose fix for arbitrary paths.

Same file, same class of bug as d048569 (which stopped the script guessing Syncthing's config location) — that commit quoted the paths it introduced, but this pre-existing one was left as found.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions