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

nsis can't install the app for all users on some PC #4065

Closed
Zver64 opened this issue Jul 17, 2019 · 30 comments
Closed

nsis can't install the app for all users on some PC #4065

Zver64 opened this issue Jul 17, 2019 · 30 comments
Labels

Comments

@Zver64
Copy link

Zver64 commented Jul 17, 2019

  • Version: 20.44.4
  • Target: windows

I have created an installer using electron-builder settings below:

"build": {
    "productName": "MyApp",
    "appId": "com.MyApp",
    "extraResources": [
      {
        "from": "./someApp/someApp.exe",
        "to": "someApp.exe"
      },
      {
        "from": "./someApp/someApp.config.yaml",
        "to": "someApp.config.yaml"
      }
    ],
    "directories": {
      "output": "build"
    },
    "files": [
      "dist/electron/**/*"
    ],
    "win": {
      "icon": "build/icons/icon.ico",
      "requestedExecutionLevel": "requireAdministrator"
    },
    "nsis": {
      "oneClick": false,
      "perMachine": true,
      "allowToChangeInstallationDirectory": true
    }
  },

I have installed the app on few machines and there were two PC where I couldn't install it. Here is what I get:
image

it says: Installation Aborted. Setup was not completed successfully.

I have no idea why this happens, and how to fix it. Does anybody know why it might happen?
This problem appears on two machines out of 7 I have tested so far. Both run windows 10.

@jzhangdev
Copy link

Same problem with @Zver64 .
I use [email protected] build on window 10.

@chrisckc
Copy link

Same issue for me using 20.43.0

Upgraded to 20.44.4, no difference

Downgraded to last known working version, 20.38.5 and works fine again, installed/upgraded no problem

electron-builder-issue

config:

"nsis": {
      "oneClick": false,
      "perMachine": false,
      "allowToChangeInstallationDirectory": true
    },

app was built on Mac.
Maybe related to upgrading as the installer says an existing installation was detected. I haven't yet tried in as a clean install. Will do a bit more testing later.

Another one: #4057

@Zver64 Zver64 closed this as completed Jul 18, 2019
@Zver64 Zver64 reopened this Jul 18, 2019
@Zver64
Copy link
Author

Zver64 commented Jul 18, 2019

I am experimenting with settings as well. I removed perMachine and now it works perfectly on one of test machines, but not on another one. I am able to install it for current user only. But not for all users.

@chrisckc
Copy link

chrisckc commented Jul 18, 2019

The installation aborts immediately after clicking the "Install" button on the choose install location dialog.

I noticed when the installer detects an existing installation making the app install as an upgrade, the installation path was listed as \AppData\Local\Programs\<packagejson.name>\<packagejson.build.productName> however the <packagejson.name> part did not match what i currently have in my package.json file, it instead was matching the existing installation directory path found in the registry at HKEY_CURRENT_USER\Software\<installation-guid>\InstallLocation

At some point in the past i implemented testing and staging builds by changing the package.json "name" and "build.productName" properties. Initially i was only changing the "build.productName" and 'build.appId" properties which did not actually change the installation directory and add-remove-programs / registry entry until i found out about "build.extraMetadata" which also allowed the 'name" property to be changed. It looks like i had an existing installation with the intended productName but the name left unchanged, making the installer detect the productName and try to use an incorrect installation directory found in the registry.

I tried installing as a fresh installation, deleting the app dir from %USERPROFILE%\AppData\Local\Programs\<packagejson.name> did not make the installer think that the app is not installed, uninstalling from add-remove programs also did not do the trick. It looks at the registry key in HKEY_CURRENT_USER\Software\<installation-guid> which seems to have been left behind during the uninstall. Once that is deleted it installs as a fresh installation.

Installing as a fresh installation solved the issue and i was also unable to recreate the issue by upgrading. I tested it by creating 3 builds using 20.38.5, 20.43.0 and 20.44.4 and them installing them in sequence.

It seems that the issue was caused by the presence of a previous installation built using a different configuration of package.json name and build.productName settings. I think some work needs to be done to improve the error handling here as it does not fail nicely. I also could not find any installation logs, although it didn't spend too long looking, anyone know where to find them?

@chrisckc
Copy link

chrisckc commented Jul 18, 2019

Ok, seems like the above is not the complete story, there seems to be an issue with the installation directory depending if a one-click unattended installer or an attended installer is created.

I recently added this section to my package.json build config:

"nsis": {
      "oneClick": false,
      "perMachine": false,
      "allowToChangeInstallationDirectory": true
    },

Without the above section, an unattended one-click installer is created which on a clean installation installs the app into: \AppData\Local\Programs\<packagejson.name>\ so unless you use the "build.extraMetadata" option to change the "name" property, multiple apps with different "productName" values overwrite each other despite creating separate registry entries and desktop shortcuts (which seem to be based on the productName.

When adding the above config which creates the attended installer, on a clean install the app is installed into: \AppData\Local\Programs\<packagejson.build.productName> allowing separate app installations to be created without having to change the "name " property.

If the app is installed first using the one-click installer and then installed over the top using the attended installer, the attended installer detects an existing installation at \AppData\Local\Programs\<packagejson.name>\ , then removes the contents of the directory and installs the app at: \AppData\Local\Programs\<packagejson.name>\<packagejson.build.productName> instead of \AppData\Local\Programs\<packagejson.build.productName>
uninstalling the app then leaves behind an empty \AppData\Local\Programs\<packagejson.name>\ directory but does correctly remove the registry entries.

I was not able to reproduce the issue by performing the above steps, so likely it was caused by the changes i had made over time.

@Zver64
Copy link
Author

Zver64 commented Jul 19, 2019

If the app is installed first using the one-click installer and then installed over the top using the attended installer, the attended installer detects an existing installation at \AppData\Local\Programs\<packagejson.name>\ , then removes the contents of the directory and installs the app at: \AppData\Local\Programs\<packagejson.name>\<packagejson.build.productName> instead of \AppData\Local\Programs\<packagejson.build.productName>

I have the same issue when using:

{
  "oneClick": false,
  "allowToChangeInstallationDirectory": true
}

and custom "customRemoveFiles" macro which leaves the app folder and one of my subfolders. Here is the issue: #4056
Looks like if the folder where you want to install your app already exists and it's not named as your "build.productName", then it will create a subfolder named as in your "build.productName" and install the app in it.

@mastergberry
Copy link
Contributor

Hey, some of my users are also reporting this issue. Is there any debug logs or something to try and resolve the issue?

"nsis": {
      "oneClick": false,
      "perMachine": true,
      "allowToChangeInstallationDirectory": true
    }

My installation config is similar to the original one...so this means the installation is in C:\Program Files\{APP_NAME} by default.

There is still a directory located in AppData\Roaming\{APP_NAME}...but this is basically just the electron stuff located there like cookies, caches, storage, etc.

Is there a complete solution here to fix this? Some of my users are claiming to do full uninstalls, reinstalls, etc but still not having any luck...

@mastergberry
Copy link
Contributor

So I had a user that reported this error...and I was able to fix it. It basically relates to: #4069 (at least for me).

I deleted the old bad GUID Uninstaller from the registry and then the installation worked with no issues. Here is the code I used in nsis to basically do this:

# For my application GUID (fix GUID to match what your application uses)
!define NEW_GUID_INSTALLER "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{1de14785-dd8c-5cd2-aae8-d4a376f81d78}"
!define OLD_GUID_UNINSTALLER "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\1de14785-dd8c-5cd2-aae8-d4a376f81d78"

!macro customInit
    // Checks for if already updated to new version...so we can remove the old entry
    Call CheckForNewInstallation
!macroend

!macro customInstall
    // Remove old entry for installation for sure now if it exists, because we just installed the client
    Call CleanOldInstallation
!endmacro

Function CheckForNewInstallation
    # Preserve stack
    Push $R1
    
    # Check if new electron app is installed
    ReadRegStr $R1 HKLM "${NEW_GUID_INSTALLER}" "Publisher"
    
    # Check if this key exists or not
    StrCmp $R1 "{YOUR_PUBLISHER_NAME_HERE}" DeleteOldInstallation SkipOldInstallation
    
    DeleteOldInstallation:
        Call CleanOldInstallation
    SkipOldInstallation:
        
    # Restore stack
    Pop $R1
FunctionEnd

Function CleanOldInstallation
    # Preserve stack
    Push $R0
    
    # Check if old BL is installed
    ReadRegStr $R0 HKLM "${OLD_GUID_UNINSTALLER}" "Publisher"

    # Check if this key exists or not
    StrCmp $R0 "{YOUR_PUBLISHER_NAME_HERE}" DeleteOldEntry SkipOldEntry
    
    DeleteOldEntry:
        # Just blindly ignore errors...worst case it does nothing harmful
        DeleteRegKey HKLM "${OLD_GUID_UNINSTALLER}"
    SkipOldEntry:
    
    # Restore stack
    Pop $R0
FunctionEnd

@mastergberry
Copy link
Contributor

Still having issues on this even with the above macro/attempts to fix it.

Seems to also happen sometimes with the new GUID as well.

@mastergberry
Copy link
Contributor

Tagging @develar to try and take a look at this, as it's a pretty widespread problem since upgrading electron-updater and electron-builder for my users.

Really wish there was more detailed output from nsis as to what failed.

@mastergberry
Copy link
Contributor

Also related to: #4092

Several problems/issues between uninstallation and installation.

@DominikLevitsky
Copy link

We have a similar issue: #4474 It seems if the "perMachine" is not set, the auto-updater picks the default as for current user, and then the old installation is deleted, but the new one is not installed.

@stale
Copy link

stale bot commented Jan 26, 2020

Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward?

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

@stale stale bot added the backlog label Jan 26, 2020
@stale stale bot closed this as completed Feb 2, 2020
@harishajdarevic
Copy link

Any updates regarding this?

@jmeinke
Copy link
Contributor

jmeinke commented Mar 1, 2020

I can confirm the issue. Upgrading electron-builder
electron-builder
and changing the nsis configuration
BreakIt
results in problems with installing the new package over an existing installation:
Installer-Hangs

The new installer might work on a second try, which will also result in a non-updated + broken installation entry in the Windows programs list.

@Zver64 IMO this should be reopened

@aaclayton
Copy link

Seems to still be a problem, please re-open!

@blarfoon
Copy link

Still an issue. Please reopen

1 similar comment
@deathlyrage
Copy link

Still an issue. Please reopen

@Zver64
Copy link
Author

Zver64 commented Mar 28, 2020

I can confirm the issue. Upgrading electron-builder
electron-builder
and changing the nsis configuration
BreakIt
results in problems with installing the new package over an existing installation:
Installer-Hangs

The new installer might work on a second try, which will also result in a non-updated + broken installation entry in the Windows programs list.

@Zver64 IMO this should be reopened

I am no longer working on the project where I had this issue, but looking at the coments above it indeed seems to be a relevant issue. Although I don't know how to reopen it.

@ahadcove
Copy link

A few of my users are also having this issue. Hoping this issue could still come back to surface

@aaclayton
Copy link

aaclayton commented May 11, 2020

Definitely still seems to be an issue. Occuring for my users with electron-builder 22.6.0

@ctapisab
Copy link

Also in electron-builder 22.3.2. Please reopen.

@kierandrewett
Copy link

kierandrewett commented May 25, 2020

I've found a solution. If you're on Windows, open Programs and Features, look for your app and click uninstall. Windows had the application in cache and NSIS doesn't let you install the app if it already exists in cache.

@Zaynex
Copy link

Zaynex commented Jun 16, 2020

@Zver64 please reopen it.

@mjwvb
Copy link

mjwvb commented Jul 7, 2020

Same problem here with electron-builder 22.7.0.
I sometimes have to manually remove uninstaller registry entries to proceed with a fresh install.

@aaclayton
Copy link

Same experience for me and many of my users - registry entries are not removed when uninstalled on Windows using NSIS, have to manually go in and delete registry entries before you can proceed with a new install.

Please re-open this issue @develar, there's a lot of evidence in this thread to support this remaining an active problem.

@thomasschwarzott
Copy link

I'm currently not able to dive deeper into the topic but I ran into the same troubles today. This is my setting:

"nsis": {
            "oneClick": "false",
            "perMachine": "false",
            "allowToChangeInstallationDirectory": "true",
            "packElevateHelper": "true"
}

But - I was actually able to fix the broken installation process simply by updating electron and electron-builder:

"electron": "^9.1.0",
"electron-builder": "^22.7.0"

The project was using electron ^7.1.3 and electron-builder ^21.2.0 beforehand. Maybe that's a help for someone :-)

@0length
Copy link

0length commented Sep 5, 2020

image
May this way work..?? i must install it in this mount point for a reason but installation never be completed

my build/installer.nsh

!macro preInit
	SetRegView 64
	WriteRegExpandStr HKLM "${INSTALL_REGISTRY_KEY}" InstallLocation "C:\data_d\CS_Dashboard"
	WriteRegExpandStr HKCU "${INSTALL_REGISTRY_KEY}" InstallLocation "C:\data_d\CS_Dashboard"
	SetRegView 32
	WriteRegExpandStr HKLM "${INSTALL_REGISTRY_KEY}" InstallLocation "C:\data_d\CS_Dashboard"
	WriteRegExpandStr HKCU "${INSTALL_REGISTRY_KEY}" InstallLocation "C:\data_d\CS_Dashboard"
!macroend

my package.json

...
   "win": {
      "icon": "./icon/win32.ico",
      "target": [
        {
          "target": "nsis"
        }
      ],
      "requestedExecutionLevel": "requireAdministrator"
    },
    "nsis": {
      "oneClick": false,
      "allowElevation": true,
      "perMachine": true,
      "allowToChangeInstallationDirectory": true,
      "createDesktopShortcut": true,
      "createStartMenuShortcut": true,
      "include": "build/installer.nsh"
    }
...

@billcxx
Copy link

billcxx commented Oct 15, 2020

"electron": "^10.1.2",
"electron-builder": "^22.8.0"

same problem here. I just want to install the program to the program file folder rather than the AppData folder

@0length
Copy link

0length commented Oct 16, 2020

electron

maybe you need clear the old registry value.. i am using revo uninstaller for cleaning old registry and cache..

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

No branches or pull requests