belav / csharpier

CSharpier is an opinionated code formatter for c#.
https://csharpier.com
MIT License
1.41k stars 98 forks source link

CSharpier Process Error in VS2022 #1341

Open marss72 opened 2 months ago

marss72 commented 2 months ago

Environments

Log Output

[Info - 29.8.2024 20:07:32] Starting
[Debug - 29.8.2024 20:07:32] Ensure there is a csharpier process for D:\VS\AnyProject\AnyProject
[Debug - 29.8.2024 20:07:32] Looking for csproj in or above D:\VS\AnyProject\AnyProject that references CSharpier.MsBuild
[Debug - 29.8.2024 20:07:32] Running 'dotnet tool list' to look for version
[Debug - 29.8.2024 20:07:32] Output was: 
 Package Id      Version      Commands      Manifest
---------------------------------------------------
[Debug - 29.8.2024 20:07:33] Running 'dotnet tool list-g' to look for version
[Debug - 29.8.2024 20:07:33] Output was: 
 Package Id               Version      Commands        
------------------------------------------------------
csharpier                0.29.1       dotnet-csharpier
csharprepl               0.6.7        csharprepl      
dotnet-example           3.1.0        dotnet-example  
[Debug - 29.8.2024 20:07:33] Using 0.29.1 as the version number.
[Debug - 29.8.2024 20:07:34] dotnet csharpier --version output: 0.29.1
[Debug - 29.8.2024 20:07:34] Using 0.29.1 as the version number.
[Debug - 29.8.2024 20:07:34] CSharpier at C:\Users\admin\AppData\Local\CSharpier\0.29.1 already exists
[Debug - 29.8.2024 20:07:34] Adding new version 0.29.1 process for D:\VS\AnyProject\AnyProject
[Debug - 29.8.2024 20:07:34] Running C:\Users\admin\AppData\Local\CSharpier\0.29.1\dotnet-csharpier --server
[Warn - 29.8.2024 20:07:36] Spawning the csharpier server timed out.

[Debug - 29.8.2024 20:07:37] Ensure there is a csharpier process for D:\VS\AnyProject\AnyProject
[Debug - 29.8.2024 20:08:52] Ensure there is a csharpier process for D:\VS\AnyProject\AnyProject
[Info - 29.8.2024 20:08:54] Formatting started for D:\VS\AnyProject\AnyProject\Program.cs using CSharpier 0.29.1
[Warn - 29.8.2024 20:08:54] CSharpier process failed to start. Formatting cannot occur.
[Info - 29.8.2024 20:08:54] Formatted in 2ms
[Info - 29.8.2024 20:08:58] Formatting started for D:\VS\AnyProject\AnyProject\Program.cs using CSharpier 0.29.1
[Warn - 29.8.2024 20:08:58] CSharpier process failed to start. Formatting cannot occur.
[Info - 29.8.2024 20:08:58] Formatted in 0ms
[Debug - 29.8.2024 20:17:09] Ensure there is a csharpier process for D:\VS\AnyProject\AnyProject
[Debug - 29.8.2024 20:17:09] Ensure there is a csharpier process for D:\VS\AnyProject\AnyProject
[Debug - 29.8.2024 20:21:26] Ensure there is a csharpier process for D:\VS\AnyProject\AnyProject

Steps to reproduce I don't know if there are any steps. But, this issue started appearing right after I switched from Visual Studio 2022 Preview (due to some issues (not csharpier)) to the stable version. Since this switch, the issue now appears on both versions.

Expected behavior After starting Visual Studio 2022, CSharpier process and extension will load successfully and formatting will be available.

Actual behavior Sometimes (usually once every day, doesn't seem to have any "pattern"), CSharpier process will fail to load and formatting is not available with the following Visual Studio message:

CSharpier could not be set up properly so formatting is not currently supported. Read More 

As I said, this usually gets fixed by just restarting the IDE - but this is just a temporary fix and the error appears again after some time (a few hours usually), or sometimes (not always) on another IDE restart.


I tried the steps in Editor Troubleshooting at least twice: reinstalling CSharpier (also with deleting the %localappdata%\CSharpier), reinstalling the extension and checking for updates. Did not help. I will let you know if I manage to fix it without re-installing the whole IDE (I will reinstall soon if this issue does not stop.)

marss72 commented 2 months ago

I repaired the Visual Studio 2022 and uninstalled the Preview version. Also deleted CSharpier before first turning the repaired version on and installing the extension - the same error keeps showing.

belav commented 2 months ago

I haven't updated the troubleshooting steps to include information for the new csharpier server. I believe there should be a server.log file next to the file at C:\Users\admin\AppData\Local\CSharpier\0.29.1\dotnet-csharpier. Hopefully that shows why the process is unable to start the server.

As a workaround there is an option to disable csharpier server. I'm also considering making the extension automatically fall back to disabling csharpier server, but ideally I'd get the problems in csharpier server resolved and I can't resolve them if they aren't reported.

marss72 commented 2 months ago

Yes, I've been checking the settings and turned the CSharpier server off and everything works fine now. An automatic fallback would be a great idea.

About the server.log, there is no such file in that directory.

Eptagone commented 4 days ago

I have the same problem using Rider and as @marss72 mentioned. It works again by disabling the CSharpier server. It's a little strange because the first time I installed the plugin it worked but the next day, it stopped working.

marss72 commented 4 days ago

I have the same problem using Rider and as @marss72 mentioned.

The issue stopped somehow for me since I installed Rider. I haven't used Visual Studio in longer coding sessions (> 2 hours) since that moment.

It's a little strange because the first time I installed the plugin it worked but the next day, it stopped working.

The same thing happened to me too. Everything worked fine, but after a few days, this error started happening.