There's a very special place in hell for programs whose searchpath defaults to current dir.

There's an even more special place in hell for programs that provide no mechanism to specify the searchpath.

It's this extremely windows mentality.

And while I'm ragging on bad places to put your user configs and ancillary data...

Don't place data relative to your executable. Just don't. Finding yourself is a pain and it's a dumb idea because you don't know where that exe's gonna be.

If I can't just put your application in /bin, that is a bug.

Show thread

Once and for all, if you want to know where to put user config and data, search these in this order:

1) Environment variable. $APP_THING (config, data, etc). Not necessary for all apps, but if you're... say... MAME, and your configs are probably right next to 700GB of ROMS... yeaaaah probably add this one so users can point you to that second hard drive they've got.

2) /etc/app: this is where SYSTEM defaults live. If it exists, load it and continue searching. Use the values here as fallback.

Show thread

3) $XDG_CONFIG_HOME/app: this is skippable, but it's where most modern users expect you to create your configs and is better than the Old Ways in that it makes $HOME less cluttered and makes it easier to version-control your config files. (If this isn't set, default to $HOME/.config)

4) $HOME/.app: if you accept the above, this is optional. Otherwise... uh... everything goes here. Create if does not exist.

Oh and accept ~ and $ENVVARS in your config. FFS.

Show thread

And finally, if you put an option for a relative path into your config, it should be relative to the folder the config file was located in (or if it's from /etc, where the config file would have been). NOT FROM CWD. (I mean unless your config was in CWD... You can search CWD for a config if you want I guess. But I'd advise against it unless you're on Windows).

Yes, MAME. I am calling you out.

Sign in to participate in the conversation

cybrespace: the social hub of the information superhighway jack in to the mastodon fediverse today and surf the dataflow through our cybrepunk, slightly glitchy web portal support us on patreon or liberapay!