fsprojects / Paket

A dependency manager for .NET with support for NuGet packages and Git repositories.
https://fsprojects.github.io/Paket/
MIT License
1.99k stars 520 forks source link

`paket.exe restore` hangs after (successfully) finishing its job #4215

Open mbodm opened 12 months ago

mbodm commented 12 months ago

Hey,

posted this already in https://github.com/fsprojects/Paket/issues/3412 but it seems this has no effect, since that Issue is rather old. So i decided to open a new issue.

We have somewhat same problem here, as in https://github.com/fsprojects/Paket/issues/3412 issue. All stuff is done and paket.exe restore simply not returns. But there seems to be no activity.

I attached 2 screenshots here:

After the CloseFile() (Screenshot2) nothing happens, but paket.exe in our script not returns (Screenshot1).

Additional informations:

Used environment:

We are a big company (but using my personal GitHub account here), developing and maintaining 1 giant .NET enterprise software product and we use paket.exe since years now. And this is a non-critical (but annoying) problem we have, since quite a while. The paket.exe restore does what it should (restore packages) and all is fine. The paket.exe simply not returns. We "fixed"it, by using a self-written tool, that scans for a paket.exe process and, if found, kills the process, so our script can continue then. But that´s more of a band aid patch than a solution. 😉

Any help is very appreciated!

Best regards

ConsoleOuput ProcessMonitor

smoothdeveloper commented 12 months ago

Could you somehow:

I don't think I've faced this (as a long time user) but I'm never using custom sources that require anything fancy but plain nuget.org, public sources, or folder access for example.

It may be relevant that you share what may be relevant information about your paket.dependencies/lock files if you have ability.

mbodm commented 11 months ago

Hi,

thanks a lot for the fast reply! I will try to supply what you asked for. Could take a bit of time maybe.

FYI: I assume this issue is the same effect as in this issue: https://github.com/fsprojects/Paket/issues/4216

paket.exe restore is just using restore as argument, but i assume it is the exact same problem. So its maybe not a restoreproblem and more of a general paket.exe problem. Maybe it’s something Win11 related. I don’t know.

smoothdeveloper commented 11 months ago

It would be interesting also, to see if there are subprocesses that paket would launch (such as dotnet itself).

Maybe there is some kind of deadlock over files, when dotnet commands may be spawned by paket? (I'm not sure the implementation is doing this, just trying to look for hypothesis that the hanging could also be in an external process).

Also, some commands has to scan all paket.references in your tree, you may consider trying to identify, if a part of your tree is causing the issue in particular, it may help you do a surface binary search on this hypothesis.

mbodm commented 11 months ago

Should i not see the spawned child procs in ProcesssMonitor or ProcessExplorer then?

smoothdeveloper commented 11 months ago

Yes, you definitely would see such processes.

mbodm commented 11 months ago

Is there some documentation about compiling/building paket.exe so i can build it on my own (to inspect what’s going on)?

PS: I’m an experienced (~20 years) C#/.NET software dev, but i never wrote a single line of F# 😄

mbodm commented 11 months ago

@smoothdeveloper

Just as some form of update: We are still in the process of analyzing stuff. I will let you know, as soon as we have some further information. But it could take a while. Rather busy at the moment. 😉

smoothdeveloper commented 11 months ago

@MBODM no issue and sorry I didn't see your previous message up to now either...

To build, I recommend a windows machine with VS 2019 and the 4.6.1 targeting pack, it should work relatively smoothly with just a call to the build.cmd, and then in Visual Studio.

With VS 2022, somehow I'm facing issues with .net targeting pack which are cumbersome to figure out.

Stepping into the code / attaching to the process works the same as with C#/VB.NET so just overlook the syntax in meantime, I'm confident you'll be able to get to the bottom of where the process is hanging, form which point, people with more knowledge of the paket implementation may be able to provide guidance on ways to fix the issue.

Please bring build issues (text output) in this thread if you face anything that would feel like it is blocking you.

mbodm commented 11 months ago

Hmm,

we are still investigating and i am still not sure what it´s all about.

At the moment i can state the following facts:

Result: image

Then we do the following things:

Result: image

As you can see, wether the renamed paket.exe nor the un-renamed paket.bootstrapper.exe return to the terminal. Even CTRL+C or CTRL+X can break it and you have to close the terminal.

The red output is the exact german translation of the one in this Paket GitHub issue: https://github.com/fsprojects/Paket/issues/1271

We are using paket.exe in magic mode, like it is described here: https://fsprojects.github.io/Paket/bootstrapper.html#Magic-mode

Maybe you have some hints for us? Do we something wrong?

mbodm commented 11 months ago

We finally can reproduce it! 😃

What we do (step1):

Result of step1: All works fine and paket.exe returns to terminal.

Now we do the following instead (step2):

Result of step2: The problem occurs and paket.exe does not return to terminal.

Used environment is a Windows 11 machine (details see in the opening post).

What we can say for sure:

Any help is very appreciated.

PS: We also tried using paket.exe.config and/or paket.Bootstrapper.exe.config files with BootstrapperOutputDir option. It seems to have no effect. The paket folder is always created under the user´s temp folder. We followed this guidlines: https://fsprojects.github.io/Paket/bootstrapper.html But maybe we missunderstand the sense of this parameter. But that doesn´t change the facts anyway.

ChrSteinert commented 9 months ago

I tried to reproduce it on a Windows 10 with active Defender on it. Even creating the paket folder in the Temp directory manually did not reproduce your issue.

I would also suggest, what has been before; get a version of paket with symbols, when it hangs, get a dump or attach a debugger and get us the line of code, where the hang occurs.

mbodm commented 9 months ago

First: Thx for the reply!

I have no news about the issue, but i just dropped in, to say: „Try it on a Windows 11 machine.“

I have no (easy) access to a Windows 10 machine (to compare behaviours) in my company. Not sure about Windows 11 is the problem here, but i only can say the above, already said, things. And i can say that i used a 4 weeks old Windows 11 machine, fresh installed. I downloaded and used Paket.exe in bootstrapper mode, the typical way, when i did the tests. I also made sure no Virus-Scan stuff was running or involved (not even Windows Defender).

Sadly, there is no time for debugging and hunting open source tool bugs, in my company, at the moment. At the moment, we fixed the problem, simply by using it in non bootstrapper mode or not using it at all. 😿

I just can advice you to follow the steps in the July 18th posts above, on a Windows 11 machine.

ChrSteinert commented 9 months ago

Ok – so you expect me/the maintainers to have a Win11 ready for testing, but you, using this free product for commercial gain, cannot invest the time to attach a debugger once, to assist us volunteers helping you fix your problem for free?

For someone with your experience it should be an easy task to get us the line of code, that hangs from attaching a debugger. I would even take a process dump, and analyze that for you (which is literally right click -> Create Dump, and upload to GitHub), if you say it’s to much to ask of your company to invest the few minutes the debugger thing would take to further a free product, that they benefit from, and seem to, a certain extend, to rely on.

mbodm commented 9 months ago

Hi,

hmm... ok. Sorry, if i said something wrong above. Not sure about it, when i read between your lines.

Let me add 3 statements here:

1) Your first question: Yes. That´s exactly what i would assume. That you are capable to test your own software. "Assume", not "expect".

2) Don´t get me wrong: I am an open source contributor and a friend (i can´t find a better word, since english is not my native language) of open source software since more than 2 decades. And also the Paket tool is/was very appreciated. And i/we are totally aware of the fact, that it´s a helpful addition to a .NET (Classic Framework) toolbox.

But i want to make 1 thing absolutely clear here: I/We did not expect anything from you, or from the maintainers. And i also not really get, where, in my above posts, i ever showed an "i expect this from you guys" stance.

Also please don´t missunderstand my intension, with that issue. My major intention, way before our own commercial benefits, was exactly for the reason you talk about: To give something back and let you know that issue. I had 2 other possibilities: a) Do nothing and call it a day. b) Open a halfassed 2-statements-issue. Instead i clearly inspected it (besides the debug dumb) and openend a well-documented issue here, for your (or the open source mindset´s) pleasure, not mine/our.

Foremost related to the fact, that the classic .NET Framework is more and more fading away and we anyway are 80% through the steps to use the newer SDK project style format (which makes Paket obsolete).

So you are completely free to do, with this infos or this issue, whatever you want. It´s your software and your GitHub account. You are wether related to, nor dependent on, ppls like us/me. So feel free to close the issue and/or ignore the posts above. It´s totally up to you and in my opinion i never sounded like i don´t think or expect that.

3) I quickly tested the above steps yesterday, on a private Windows 10 machine, of a friend of mine. The issue not occurred. So i assume more and more it´s a Windows 11 issue. The rest is up to you.

By the way: GitHub says above i closed the issue. I did not. Just for the sake of correctness here.

Anyway, have a nice day.


PS (directly addressed to @ChrSteinert): When i think about the open-source-mindset in general and read your post above, i am really not sure, if you should invest your time into open-source. No offense here, but talking about "we should do your job???" sounds not very open-source-compatible, to be honest.

ChrSteinert commented 9 months ago

GitHub also shows to me, that you closed the issue. I took this into account while writing which looks like throwing your hands up.

If you can, reopen it. If not I suggest creating a new one (or using the other one opens by you).

I am still convinced that the best way forward is the debugger-thing or dump which I am still open to assist with.

mbodm commented 9 months ago

Hmm, no clue why GitHub stated that. I did not closed the issue.

I try to reopen the issue now, by using the „Reopen with comment“ button below, with this comment…

Edit: Ok, that worked. Issue is open again. But feel free to close it, on your side, if you think it fits.

smoothdeveloper commented 7 months ago

@MBODM, there is a bit of C# code in this repository, and I find this particular while loop a bit suspect:

https://github.com/fsprojects/Paket/blob/11320d7ba6a615b0d309f39e242c252990567de3/src/Paket.Bootstrapper/HelperProxies/FileSystemProxy.cs#L41-L69

Can you confirm if the hang is lasting 15 minute and then it doesn't hang anymore, or it does hang for significantly longer?

Also, why do you need to use the bootstrapper? Is it for project with dotnet SDK or dotnet framework/mono only and you can't use dotnet tool restore & dotnet paket ...?