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

Multiple instances of VSCode fails #784

Closed
BenasB opened this issue Jan 9, 2023 · 6 comments · Fixed by #804
Closed

Multiple instances of VSCode fails #784

BenasB opened this issue Jan 9, 2023 · 6 comments · Fixed by #804
Labels

Comments

@BenasB
Copy link

BenasB commented Jan 9, 2023

Hi,

I had two instances of VSCode opened up and I noticed that only on one of them formatting with csharpier got executed correctly. The second one outputs:

...
["DEBUG" - 13:35:33] Unable to find dotnet-tools.json, falling back to running dotnet csharpier --version
["DEBUG" - 13:35:35] dotnet csharpier --version output 0.21.0
["DEBUG" - 13:35:36] dotnet csharpier --version output: 0.21.0
["ERROR" - 13:35:38] ,,Tool 'csharpier' is already installed.
["DEBUG" - 13:35:38] returning NullCSharpierProcess because of the previous error when trying to set up a csharpier process
["INFO" - 13:35:38] Formatted in 4514.589999999851ms
["DEBUG" - 13:35:38] result is empty

I believe this is particularly because of the Tool 'csharpier' is already installed. as it somehow fails to reuse/recreate the process? By the way I do not install csharpier locally, but I have 0.21.0 installed globally with dotnet tool.

@belav
Copy link
Owner

belav commented Jan 9, 2023

I haven't been able to recreate this, but it sounds like they were both trying to install csharpier at the same time, and the second one got an error because the first instance installed it. I'm guessing if you close out VSCode and reopen it, things will be working.

I believe it should be possible to handle this condition by looking for that specific error.

@belav belav added this to the 0.23.0 milestone Jan 9, 2023
@BenasB
Copy link
Author

BenasB commented Jan 10, 2023

Hmm, very strange, I opened up a single instance today and noticed that it wasn't formatting, this time the full output:

["INFO" - 15:10:51] Initializing csharpier-vscode
["INFO" - 15:11:47] Formatting started for c:\repos\CodeStandard-Secret\MyClassLib\Class1.cs.
["DEBUG" - 15:11:47] Ensure there is a csharpier process for c:\repos\CodeStandard-Secret\MyClassLib
["DEBUG" - 15:11:47] Looking for c:\repos\CodeStandard-Secret\MyClassLib/*.csproj
["DEBUG" - 15:11:47] Looking at c:\repos\CodeStandard-Secret\MyClassLib\MyClassLib.csproj
["DEBUG" - 15:11:47] Looking for c:\repos\CodeStandard-Secret\MyClassLib\.config\dotnet-tools.json
["DEBUG" - 15:11:47] Looking for c:\repos\CodeStandard-Secret/*.csproj
["DEBUG" - 15:11:47] Looking for c:\repos\CodeStandard-Secret\.config\dotnet-tools.json
["DEBUG" - 15:11:47] Looking for c:\repos/*.csproj
["DEBUG" - 15:11:47] Looking for c:\repos\.config\dotnet-tools.json
["DEBUG" - 15:11:47] Looking for c:\/*.csproj
["DEBUG" - 15:11:47] Looking for c:\.config\dotnet-tools.json
["DEBUG" - 15:11:47] Unable to find dotnet-tools.json, falling back to running dotnet csharpier --version
["DEBUG" - 15:11:49] dotnet csharpier --version output 0.21.0

["WARN" - 15:11:50] Exception while running 'dotnet csharpier --version' in C:\Users\MY_USER\AppData\Local\CSharpier\0.21.0
"A fatal error was encountered. The library 'hostpolicy.dll' required to execute the application was not found in 'C:\\Program Files\\dotnet\\'.\r\nFailed to run as a self-contained app.\r\n  - The application was run as a self-contained app because 'C:\\Users\\MY_USER\\AppData\\Local\\CSharpier\\0.21.0\\.store\\csharpier\\0.21.0\\csharpier\\0.21.0\\tools\\net7.0\\any\\dotnet-csharpier.runtimeconfig.json' was not found.\r\n  - If this should be a framework-dependent app, add the 'C:\\Users\\MY_USER\\AppData\\Local\\CSharpier\\0.21.0\\.store\\csharpier\\0.21.0\\csharpier\\0.21.0\\tools\\net7.0\\any\\dotnet-csharpier.runtimeconfig.json' file and specify the appropriate framework.\r\n"
["ERROR" - 15:11:51] ,,Tool 'csharpier' is already installed.

["DEBUG" - 15:11:51] returning NullCSharpierProcess because of the previous error when trying to set up a csharpier process
["INFO" - 15:11:51] Formatted in 3634.2987999999896ms
["DEBUG" - 15:11:51] result is empty

Not sure about the warning, but the error is the same.

Manually going to C:\Users\MY_USER\AppData\Local\CSharpier\0.21.0 and executing dotnet-csharpier --version displays 0.21.0 as expected.

So maybe this is not related to two instances, but rather something else

@BenasB
Copy link
Author

BenasB commented Jan 10, 2023

After waiting for a bit, one instance scenario is randomly now fixed, however I'm back to the same scenario with 2 instances running (one works ok, one fails). If I try to restart the bad instance with the good one still running, it does not help. If I exit the good instance, the bad one still fails. If I exit both instances and then start a new single instance, it works.

Not sure what is going on. I'm on windows by the way.

@belav
Copy link
Owner

belav commented Jan 21, 2023

Sorry for the delay - I'm able to reproduce this consistently now. It appears that the second instance of VSCode somehow corrupts the install of csharpier, which then leaves it in a non-working state for the second instance. The first instance continues to work because it has csharpier already running in the background. If you close out all instances, the first instances started is able to recover from the corrupted install.

I haven't had time to look into exactly why that happens, but I should have time in the next couple of days to get a fix out.

@belav
Copy link
Owner

belav commented Jan 23, 2023

This is fixed in version 1.3.6 of the extension, it should be available shortly.

@belav belav closed this as completed Jan 23, 2023
@belav belav removed this from the 0.23.0 milestone Jan 23, 2023
@BenasB
Copy link
Author

BenasB commented Jan 23, 2023

Much thanks!

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

Successfully merging a pull request may close this issue.

2 participants