Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(windows): Resolve broken installation directory handling in MSI & NSIS, preventing duplicate installations during updates #12365

Open
wants to merge 4 commits into
base: dev
Choose a base branch
from

Conversation

don41382
Copy link

This PR addresses an issue where the MSI updater installs the application to the default directory (C:\Program Files\<App Name>), even if the application was initially installed in a custom directory by NSIS, such as the user-specific path (C:\Users\<User>\AppData\Local\<App Name>).

Root Cause

The problem arises from a mismatch between NSIS and MSI in handling the installation directory path:

  • The NSIS installer sets the installation path entry as a "no-key" (standard) value.
  • The MSI updater, however, looks for a key named InstallDir to locate the existing installation directory.

Consequences

This mismatch causes MSI to fail in detecting the original installation directory during updates, resulting in two separate installations:

  • Machine-wide directory: C:\Program Files\<App Name>
  • User-specific directory: C:\Users\<User>\AppData\Local\<App Name>

Fix

This PR resolves the issue by ensuring proper handover of the installation directory between NSIS and MSI. Additionally, it ensures backwards compatibility to avoid breaking existing setups.

@don41382 don41382 requested a review from a team as a code owner January 12, 2025 13:51
Copy link
Contributor

github-actions bot commented Jan 12, 2025

Package Changes Through de0cbad

No changes.

Add a change file through the GitHub UI by following this link.


Read about change files or the docs at github.com/jbolda/covector

@FabianLars
Copy link
Member

btw just a bit of context. nsis -> msi updates were never supposed to work. officially only msi -> nsis updates are/were supported (intentionally).

@don41382
Copy link
Author

don41382 commented Jan 12, 2025

btw just a bit of context. nsis -> msi updates were never supposed to work. officially only msi -> nsis updates are/were supported (intentionally).

Thanks for the quick response. Maybe I got this wrong. You mean, that the enduser does not initially installs the app with the .exe (nsis), but rather with the .msi?

But how to I enable "installMode": "currentUser" with a .msi? I am a little bit confused.

@FabianLars
Copy link
Member

Thanks for the quick response. Maybe I got this wrong. You mean, that the enduser does not initially installs the app with the .exe (nsis), but rather with the .msi?

Nope. First of all, 99% of apps should not ship both the msi and nsis exe but decide on one format before distributing their app.

The msi -> nsis flow is supported because the nsis installer is newer and is/was the recommended installer but was added when there were already many apps using msi installers. We just wanted to give devs a way to switch to the new format if they wish too. That of course doesn't mean that we shouldn't support nsis -> msi as well, we just never saw much of a reason to.

And generally, even though cross installer updates are supported, apps shouldn't make use of that feature without good reason.

But how to I enable "installMode": "currentUser" with a .msi? I am a little bit confused.

The other way around. You would enable the perMachine mode for the nsis installer.

@don41382
Copy link
Author

Nope. First of all, 99% of apps should not ship both the msi and nsis exe but decide on one format before distributing their app.

I am shipping (user download from homepage) currently only the nsis version with "installMode": "currentUser", which I understand from your comment is the default. I think, it's the better choice, because it allows to install without requiring admin privileges.

On updating the windows version, I started to see duplicated installation on the same machine. The .msi didn't recall the correct installation directory and created a second installation in the "machine path". I guess, if you would have first started with .msi, than the "InstallIDir" would have set correctly and updating would not be a problem.

So two version existed and the Autostart ended up starting the old version. Which of course is a mess.

Maybe I am one of the few who started with distributing the nsis. Installing the .msi first, will set are correct InstallDir in the registry.

IMO tauri should support both ways and it should not matter which was installed fist - otherwise this creates just confusion. Wdyt?

@FabianLars
Copy link
Member

Maybe I am one of the few who started with distributing the nsis.

Nah, nowadays that should be more common. You just made the same mistake everyone does, also shipping the msi at the same time, or at least using it in the updater - which tbf is our fault especially if you use tauri-action which prios the msi for legacy reasons.

IMO tauri should support both ways and it should not matter which was installed fist - otherwise this creates just confusion. Wdyt?

Already said that i'm fine with that. 🤷

@don41382
Copy link
Author

Already said that i'm fine with that. 🤷

Perfect. If you are okay with the changes, than we just have to wait for @Legend-Master for his remarks regarding backwards compatibility to custom installation locations.

@FabianLars
Copy link
Member

The wix change is fine, but we need a changefile for tauri-bundler before we can merge this and all commits must be signed (only the first one is)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants