clowd / Clowd.Squirrel

Quick and easy installer and automatic updates for cross-platform dotnet applications
426 stars 39 forks source link

Access to AppData\Local\Temp\Clowd.Squirrel\temp.2 is denied #119

Closed jokyjoey closed 10 months ago

jokyjoey commented 2 years ago

Hi!

When installing my application the installation sometimes fails with the error in the following screenshot. According to the stacktrace it tries to extract the content of the package into a temporary folder but fails to access it.

grafik

I'm currently using the 3.0.210-g5f9f594 preview and I'm not entirely sure if this is a bug in Squirrel at all, but just me doing something wrong (or something else getting in the way).

Has anyone else also encountered this issue and knows how to fix this?

caesay commented 2 years ago

Hi there! you say it sometimes fails. How reproducible is this? Are you using any anti-virus software? If it's fairly reproducible and you are using AV, can you temporarily turn off your anti-virus and see if the issue still occurs?

jokyjoey commented 2 years ago

Sorry, I forgot to mention this. The error does not occur every time I run the Setup.exe but only every xth time. Interestingly it also seems to vary from machine to machine. On one device it only fails every 20th time, whereas it may fail 20 times in a row on another machine. Excluding these directories from Defender or disabling Defender completely did not seem to fix this issue unfortunately.

caesay commented 2 years ago

Are these machines joined to an active directory domain? Or have any group policies been set that might impact the system temp directory?

And have you only seen this with installing, or does it happen when Updating too?

jokyjoey commented 2 years ago

Yes the machines are indeed joined to a domain, but there are no GPOs regarding the temp directory.

The issue only occurs when doing an installation by executing the Setup.exe. Updates via the app itself (via UpdateManager) always work.

jokyjoey commented 2 years ago

Having executed the Setup.exe over a hundred times in a row now, while also watching the Clowd.Squirrel\temp.x folders, as well as the target folder. I'm still not completely sure, but for me it seems as the reason must be some kind of timing or thread blocking/overlap/order issue.

In these cases when I get the error, I can see the temp.1 and temp.2 are created and populated correctly, but the output directory (outFinalFolder) is either missing some of the files or is completely empty.

It looks like that the temporary temp.2 folder is already deleted, when the following line is executed:

https://github.com/clowd/Clowd.Squirrel/blob/5f9f594b3d20453652fde782800d9293914db44e/src/Squirrel/NuGet/ZipPackage.cs#L225

caesay commented 2 years ago

Thanks for the detailed investigation. If you don't find the issue before me, I will step through the installer at some point soon and look for potential problems.

jokyjoey commented 2 years ago

I just cloned the source code and did several runs in debug mode in VS as described in the docs. I also added several log output before/after the moving of files and the deletion of the temp folders in the hope to detect differences in both cases (see lines with >>>>>). Fortunately I was able to reproduce the issue which can be seen in the following screenshot:

grafik

As can be seen in the failing case (the part below the black line) the temp.2 is somehow deleted, but moving the files has not yet completed. There is no "...>>>>> Finished moving files..." line like it can be seen in the upper (successful) case.

I was unfortunately not able to fix this behavior, but maybe this info gives you some important hints.

Energizer188 commented 1 year ago

I stumble onto the same problem yesterday, several times in a row. I believe it has something to do with our antivirus interfering with the process. I've restarted my computer and the problem was gone. Do you sign your files? I think that might help to keep our antivirus out of it. (in my cases files were not signed).

sebaJoSt commented 1 year ago

I have the same problem now, when I install and when I update. No antivirus software besides Windows Defender is running.

Installing: Capture2

Updating: Capture

llehn commented 1 year ago

I'm having the same problem now.

Observations:

  1. happens every time on one machine when invoked via MSI installer (i.e. at Logon)
  2. does not happen when invoking the same cmd-line manually
  3. does not happen on another machine I've testet it on.

Particularly the combination of 1 and 2 kinda sucks for debugging :/

JobaDiniz commented 1 year ago

I had the same problem with the new version of Clowd.Squirrel. The exact same message box from @sebaJoSt. By running the setup as admin the problem went away.

caesay commented 1 year ago

Hi, can anyone confirming the issue please share the version of Squirrel they are using? I still can not reproduce this, and I need to know if this is specific to v3 etc.

sebaJoSt commented 1 year ago

Hey, I'm also on 3.0.210-g5f9f594.

misterio955 commented 1 year ago

I had the same problem. It turned out that the antivirus was deleting the temp folder, before has been copied.

ethranes commented 1 year ago

We have this on version

3.0.210+5f9f594

We do have antivirus, turning it off isn't really an option though

misterio955 commented 1 year ago

We have this on version

3.0.210+5f9f594

We do have antivirus, turning it off isn't really an option though

You can add policies to your antivirus that will ignore the squirrel temp folder

caesay commented 11 months ago

I am planning on fixing this on v3 by removing Squirrel's need to use a temp folder at all. This will likely not be backported to v2 due to the scale of the changes.

caesay commented 10 months ago

This is fixed in v4