D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 20489 - Installer deleting files after install
Summary: Installer deleting files after install
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: installer (show other issues)
Version: D2
Hardware: x86 Windows
: P1 enhancement
Assignee: No Owner
URL:
Keywords: pull
Depends on:
Blocks:
 
Reported: 2020-01-08 12:16 UTC by Simen Kjaeraas
Modified: 2020-02-12 21:50 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Simen Kjaeraas 2020-01-08 12:16:06 UTC
Something seems to be wrong with the 2.090.0 Windows installer. After successfully installing, it proceeds to delete every file it has just added.

Looking closely at how it happens, it seems that it might actually be caused by the uninstaller deleting itself and the directory it's in. If I wait long after the previous version has been uninstalled before clicking 'next', it doesn't happen.

So, how to reproduce:

1) have a previous DMD version installed
2) start the 2.090.0 installer
3) answer yes to uninstalling the previous version
4) quickly finish installing 2.090.0

If you do this with the install folder open in an explorer window, you should see the files disappearing during the uninstall of the previous version, until the only item in the D folder is uninstall.exe. As the new install proceeds more files and folders will be added, and finally they will all be deleted again, sometimes leaving an empty folders, other times a partial installation (I've only once managed to get a partial installation).

It seems that the installer is not waiting for the uninstall to finish before installing things, or conversely that the uninstaller signals completion before it's actually done.
Comment 1 Rainer Schuetze 2020-01-08 21:34:06 UTC
I tried to reproduce this, but for me, the uninstaller is blocking the installer until it is finished. The NSIS script is using an ExecWait statement to run the uninstaller.

Maybe ExecWait doesn't work for some reason. What Windows version are you running? Mine is Win 10 1903. What version are you uninstalling?
Comment 2 Simen Kjaeraas 2020-01-09 08:43:37 UTC
Win10 1903, so that shouldn't be it. Could be work's overzealous antivirus or somesuch, I guess. Tested it both upgrading from 2.089.0 and just reinstalling 2.090.0 over the botched 2.090.0 install I ended up with. In total I tried it 7 or 8 times, and managed to recreate the issue 4 or 5 times.

I tried it again on a different computer today (but still a work machine, so could still be their antivirus - I'll be trying it at home tomorrow), and after seven installs didn't manage to get it to remove every single file even once, but had partial installs five times. I tried this with both 2.090.0 and 2.078.0 with identical results.
Comment 3 Simen Kjaeraas 2020-01-10 23:03:52 UTC
Tested at home today, and I'm unable to recreate the issue. Looking at the install folder uninstall.exe is deleted within a quarter second of the uninstaller completing, while this would take several seconds at work.

Looking at the .nsi script there is a 1s sleep after the uninstaller returns before the uninstaller is invoked again in an Exec statement, which doesn't wait for its completion.

Conceivably this could be an ExecWait, or uninstall.exe's existence could be tested before the copying of files starts.
Comment 4 Dlang Bot 2020-02-08 09:15:14 UTC
@rainers created dlang/installer pull request #428 "[WIP] fix Issue 20489 - Installer deleting files after install" fixing this issue:

- fix Issue 20489 - Installer deleting files after install
  
  wait for uninstaller to terminate

https://github.com/dlang/installer/pull/428
Comment 5 Rainer Schuetze 2020-02-08 09:50:18 UTC
(In reply to Simen Kjaeraas from comment #3)
> Conceivably this could be an ExecWait, or uninstall.exe's existence could be
> tested before the copying of files starts.

Please try the win_release artifact fom https://dev.azure.com/dlanguage/Installer/_build/results?buildId=7719&view=artifacts&type=publishedArtifacts
Comment 6 Simen Kjaeraas 2020-02-12 09:14:23 UTC
Out of 15 attempts, I've managed to get a borked install once. That's even stranger, so I'm prepared to call it a fluke and say the fix works - at the very least the incidence rate is a lot lower.
Comment 7 Dlang Bot 2020-02-12 09:21:29 UTC
dlang/installer pull request #428 "[WIP] fix Issue 20489 - Installer deleting files after install" was merged into master:

- d65cac1c1c699cc55dc38af76b634a043c3c1ac3 by Rainer Schuetze:
  fix Issue 20489 - Installer deleting files after install
  
  wait for uninstaller to terminate

https://github.com/dlang/installer/pull/428
Comment 8 Rainer Schuetze 2020-02-12 21:50:44 UTC
Thanks for testing and the hint at the error.