How does changing the location of the configuration file work?

I’d like to change the location of Syncthing’s configuration file. There are a couple of questions about this on the forum, but the only direct answer is a terse “syncthing -home /new/directory” without enough information for me to tell exactly what that does.

In trying to deduce it based on what’s in the documentation, I presume there must be some place under the hood where Syncthing records where to look for its database and config file. So, if I want to change those, do I

  1. Run $ syncthing -home /new/directory once as a configuration command to tell Syncthing to edit what’s under the hood to record the new location of its config & data directory, or
  2. Run $ syncthing -home /new/directory every time I issue a Syncthing command, now and forever into the future?

In the case of 2), I’m guessing that Syncthing has the default locations for its config & data directory hard-coded, and that those can’t be changed in general.

In conceptual terms, my question is, is syncthing -home /new/directory a “start the server, but with special parameters” command, or is it a “alter the internal state without doing anything to the server” command?

Alternative two, or set the corresponding env var.

Some Syncthing options, including these below, need to be used at startup to work, unless you set them as environment variables.

See Command Line Operation — Syncthing documentation and scroll down to Common Options:

–home=, -H ($STHOMEDIR)

Set common configuration and data directory. The default configuration directory is $XDG_STATE_HOME/syncthing or $HOME/.local/state/syncthing (Unix-like), $HOME/Library/Application Support/Syncthing (Mac) and %LOCALAPPDATA%\Syncthing (Windows).

–config=, -C ($STCONFDIR)

Set configuration directory. Alternative to --home and must be used together with --data.

–data=, -D ($STDATADIR)

Set data (e.g. database) directory. Alternative to --home and must be used together with --config.

1 Like

OK, thanks!