vscode-csharp
vscode-csharp copied to clipboard
C# code analysis fails to initialize with error `System.ArgumentException: filePath`
Environment data
dotnet --info
output:
.NET SDK:
Version: 8.0.105
Commit: eae90abaaf
Workload version: 8.0.100-manifests.796a77f8
Runtime Environment:
OS Name: ubuntu
OS Version: 24.04
OS Platform: Linux
RID: ubuntu.24.04-x64
Base Path: /usr/lib/dotnet/sdk/8.0.105/
.NET workloads installed:
Workload version: 8.0.100-manifests.796a77f8
There are no installed workloads to display.
Host:
Version: 8.0.5
Architecture: x64
Commit: 087e15321b
.NET SDKs installed:
8.0.105 [/usr/lib/dotnet/sdk]
.NET runtimes installed:
Microsoft.AspNetCore.App 8.0.5 [/usr/lib/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 8.0.5 [/usr/lib/dotnet/shared/Microsoft.NETCore.App]
Other architectures found:
None
Environment variables:
Not set
global.json file:
Not found
VS Code version: 1.89.1 C# Extension version:
- C#: v2.30.28
- C# Dev Kit: v1.6.8
Steps to reproduce
I do not know how to get it into this state, but it happened for me and now I don't know how to get it out of this state. I have been developing a system daemon which requires me to run my debug processes as root
, so I have by necessity been running VS Code as root
:
> code --no-sandbox --user-data-dir /root/vscodedatadir
For whatever reason, code analysis (the editor knowing about types and members and errors and such in realtime) never worked as root
, but when I'd switch back to running as my regular user, it'd be working there -- until it wasn't.
Expected behavior
When editing C# code with the C# Dev Kit installed, the editor should know about data types, members, errors and such in realtime. IntelliSense should be able to tell me what members are actually available in a given operation. "Go To Definition" should work. If I write code that contains a semantic error, it should be highlighted promptly.
Actual behavior
Visual Studio Code behaves largely as if the C# Dev Kit is not installed. It does highlight C# code (though I think it knows how to do this even without the C# Dev Kit being installed), but IntelliSense doesn't know anything about types or their members. For instance, when I press '.' after an expression of object type, I expect a popup listing the members of the associated type, but either no popup appears, or a popup appears that just contains every single identifier collected from all over my project (actually I think this latter happens when I start typing a word after '.'). Imported types are not recognized, and errors are not highlighted.
On startup, an error message appears in a toast:
Ⓧ Microsoft.CodeAnalysis.LanguageServer client: couldn't create connection to server.
It has a button to take me to the associated Output window, in which I find the following log output:
Using dotnet configured on PATH
Dotnet path: /usr/lib/dotnet/dotnet
Activating C# + C# Dev Kit...
waiting for named pipe information from server...
[stderr] Unhandled exception: [stderr] System.ArgumentException: filePath
at Microsoft.VisualStudio.Telemetry.CommonProperty.CommonPropertyParserFactory.GetCommonPropertyParser(TelemetrySessionInternalBase session)
at Microsoft.VisualStudio.Telemetry.TelemetrySessionInternalBase.LoadCommonProperties()
at Microsoft.CodeAnalysis.LanguageServer.Logging.VSCodeTelemetryLogger.InitializeSession(String telemetryLevel, String sessionId, Boolean isDefaultSession)
at Microsoft.CodeAnalysis.LanguageServer.Logging.RoslynLogger.Initialize(ITelemetryReporter reporter, String telemetryLevel, String sessionId) in /_/src/Features/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/Logging/RoslynLogger.cs:line 41
at Program.<<Main>$>g__RunAsync|0_0(ServerConfiguration serverConfiguration, CancellationToken cancellationToken) in /_/src/Features/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/Program.cs:line 92
at System.CommandLine.CliCommand.<>c__DisplayClass32_0.<<SetAction>b__0>d.MoveNext()
--- End of stack trace from previous location ---
at System.CommandLine.Invocation.InvocationPipeline.InvokeAsync(ParseResult parseResult, CancellationToken cancellationToken)
Language server process exited with 1
[Error - 23:40:08] Microsoft.CodeAnalysis.LanguageServer client: couldn't create connection to server.
Error: Language server process exited unexpectedly
at ChildProcess.<anonymous> (/home/logiclrd/.vscode/extensions/ms-dotnettools.csharp-2.30.28-linux-x64/dist/extension.js:2:1294339)
at ChildProcess.emit (node:events:529:35)
at ChildProcess._handle.onexit (node:internal/child_process:292:12)
Additional context
I have tried reinstalling the C# Dev Kit, including deleting the associated folders from ~/.vscode/extensions
completely.
I used ILSpy to find out what exactly is happening at the point of the error, and it appears that the Language Server process expects to receive an operating parameter in an environment variable, either CommonPropertyBagPath
or CommonPropertyBagWithConfigPath
, and neither is present.