0install / 0install-win

Windows version of Zero Install
https://0install.net
GNU Lesser General Public License v3.0
157 stars 24 forks source link

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

Closed Destroy666x closed 1 year ago

Destroy666x commented 1 year ago

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:

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

bastianeicher commented 1 year ago

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

Destroy666x commented 1 year ago

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.

bastianeicher commented 1 year ago

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

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.

bastianeicher commented 1 year ago

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

Destroy666x commented 1 year ago

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?

bastianeicher commented 1 year ago

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.