0install/0install-win

Unexpected effects of setting XDG_CONFIG_HOME env to custom directory on Windows 10

Destroy666x opened this issue · 6 comments

I set my %XDG_CONFIG_HOME% env to a dir on another disk on Windows 10 for backup purposes of apps like git, GitHub CLI, etc. It works fine for them.

However, after a bit I've noticed that:

  • 0install.net folder appeared there, not a big deal
  • DeepL app that uses this installer started throwing errors (Windows notifications) like Karma is signed with untrusted keys! or Feed https://appdownload.deepl.com/windows/0install/deepl.xml failed to download, when it's trying to look for updates or autoupdate, I presume

Is that intended? Is there anything I or the devs or DeepL can do to prevent these errors?

Moving the contents of %APPDATA%\0install.net to %XDG_CONFIG_HOME%\0install.net, overwriting any files that are already there, should do the trick.

Thanks, I'm trying that right now.

Is there no way to make the installer prefer %APPDATA% over %XDG_CONFIG_HOME% on Windows? Or maybe even %LOCALAPPDATA% since there doesn't seem to be anything that's suited for Roaming, just some app install related configs/databases that I'm not convinced you want to share between environments/machines.

0install uses both %APPDATA% and %LOCALAPPDATA%:

  • %APPDATA%\0install.net holds config, list of trusted signatures, list of installed apps, etc.
  • %LOCALAPPDATA%\0install.net holds caches, binaries, etc..

If you roam your Windows profile to another machine, this allows 0install to still know which apps were installed in that profile, while re-downloading the app binaries only on-demand.
You can find more details in the docs.

Preferring XDG_CONFIG_HOME over APPDATA is intentional. Just like your use case with Git, users may wish to specify a custom location to store 0install config. XDG_CONFIG_HOME can be set for this purpose while APPDATA cannot be easily changed.

In case you're curious, the code 0install uses for picking various directories on different platforms lives here.

I see, I didn't notice any configs, maybe because I didn't configure anything, I just made an install of DeepL through choco. The on-demand download makes sense, too.

One last thing I'm confused about is why only half of the files were moved to newly set XDG_CONFIG_HOME and lack of moving the rest caused the errors. Shouldn't all of them be? Or I guess some were just created and none moved?

I believe something roughly like this happened:

  1. You ran DeepLSetup.exe (via Chocolatey).
  2. DeepLSetup.exe internally used 0install to download and setup the DeepL app.
    For this, 0install:
    • recorded DeepL's OpenPGP key as trusted for appdownload.deepl.com in %appdata%\0install.net\injector\trustdb.xml
    • recorded the DeepL app as installed in %appdata%\0install.net\desktop-integration\app-list.xml
    • placed the DeepL App binaries in %localappdata%\0install.net\implementations
  3. You set %XDG_CONFIG_HOME% causing 0install to now look there instead of %appdata%.
  4. The next time 0install ran, it recreated its default (mostly empty) config files, now in %XDG_CONFIG_HOME%\0install.net.
  5. When checking for updates for DeepL, 0install no longer knew which OpenPGP key to trust, because the entry made by DeepLSetup.exe wasn't present in the new %XDG_CONFIG_HOME%\0install.net\injector\trustdb.xml. Therefore update checks failed, reporting untrusted keys.

If, e.g., on a different machine, you were to set XDG_CONFIG_HOME first and then install DeepL, I expect everything should work out of the box.