dotnet / aspire

An opinionated, cloud ready stack for building observable, production ready, distributed applications in .NET
https://learn.microsoft.com/dotnet/aspire
MIT License
3.63k stars 408 forks source link

VS Code debugging in Linux (WSL) doesn’t work when environment variables "name" or "shell" are set #5389

Open GabrielLetourneau opened 3 weeks ago

GabrielLetourneau commented 3 weeks ago

Is there an existing issue for this?

Describe the bug

When running the Aspire starter project in VS Code, in WSL, with environment variables "name" or "shell" (NB: lowercase) set to any value, project resources fail to start. Dashboard is up, and I can set breakpoints in the AppHost project.

I get this in the debug console (with "name" set to "nix-shell-env"):

info: Aspire.Hosting.DistributedApplication[0]
      Login to the dashboard at https://localhost:17226/login?t=1c0bf17cb021e507e5cd8ed9f330a823
Aspire.Hosting.DistributedApplication: Information: Login to the dashboard at https://localhost:17226/login?t=1c0bf17cb021e507e5cd8ed9f330a823
Aspire.Hosting.DistributedApplication: Information: Distributed application started. Press Ctrl+C to shut down.
info: Aspire.Hosting.DistributedApplication[0]
      Distributed application started. Press Ctrl+C to shut down.
fail: Aspire.Hosting.Dcp.dcpctrl.ExecutableReconciler[0]
      run session could not be started: IDE returned a response indicating failure  {"Executable": {"name":"apiservice-bn1s3j217g"}, "Reconciliation": 2, "Status": "500 Internal Server Error", "Body": "An element with the same key but a different value already exists. Key: 'name'"}
Aspire.Hosting.Dcp.dcpctrl.ExecutableReconciler: Error: run session could not be started: IDE returned a response indicating failure    {"Executable": {"name":"apiservice-bn1s3j217g"}, "Reconciliation": 2, "Status": "500 Internal Server Error", "Body": "An element with the same key but a different value already exists. Key: 'name'"}
fail: Aspire.Hosting.Dcp.dcpctrl.ExecutableReconciler[0]
Aspire.Hosting.Dcp.dcpctrl.ExecutableReconciler: Error: run session could not be started: IDE returned a response indicating failure    {"Executable": {"name":"webfrontend-dgk1kkk60k"}, "Reconciliation": 5, "Status": "500 Internal Server Error", "Body": "An element with the same key but a different value already exists. Key: 'name'"}
      run session could not be started: IDE returned a response indicating failure  {"Executable": {"name":"webfrontend-dgk1kkk60k"}, "Reconciliation": 5, "Status": "500 Internal Server Error", "Body": "An element with the same key but a different value already exists. Key: 'name'"}

These environment variables are automatically set by the Nix shell, so this prevents me from using Aspire within a Nix development environment. NB: I also get the error without Nix installed, as long as "name" or "shell" are exported.

Running the Aspire app with dotnet run works fine.

Expected Behavior

I expect to be able to debug projects in VS Code run within a Nix development environment.

Steps To Reproduce

In WSL:

mkdir test
cd test
dotnet new aspire-starter
export name=nix-shell-env
code .

… then press F5 and select "test.AppHost".

Same thing happen with export shell=/usr/bin/bash. Then if I do this:

export -n name
export -n shell
code .

… then debugging works fine.

Exceptions (if any)

No response

.NET Version info

.NET SDK: Version: 8.0.108 Commit: 665a05cea7 Workload version: 8.0.100-manifests.a22b3d1f

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.108/

.NET workloads installed: Workload version: 8.0.100-manifests.a22b3d1f [aspire] Installation Source: SDK 8.0.100 Manifest Version: 8.1.0/8.0.100 Manifest Path: /home/gabriel/.dotnet/sdk-manifests/8.0.100/microsoft.net.sdk.aspire/8.1.0/WorkloadManifest.json Install Type: FileBased

Host: Version: 8.0.8 Architecture: x64 Commit: 08338fcaa5

.NET SDKs installed: 8.0.108 [/usr/lib/dotnet/sdk]

.NET runtimes installed: Microsoft.AspNetCore.App 8.0.8 [/usr/lib/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.NETCore.App 8.0.8 [/usr/lib/dotnet/shared/Microsoft.NETCore.App]

Other architectures found: None

Environment variables: Not set

global.json file: Not found

Learn more: https://aka.ms/dotnet/info

Download .NET: https://aka.ms/dotnet/download

Anything else?

$ code --version
1.92.2
fee1edb8d6d72a0ddff41e5f71a671c23ed924b9
x64

ms-dotnettools.csdevkit: v1.9.55 ms-dotnettools.csharp: v2.39.29

davidfowl commented 3 weeks ago

cc @karolz-ms

karolz-ms commented 2 weeks ago

It sounds like this might be an issue with the IDE tooling. CC @BillHiebert

BillHiebert commented 2 weeks ago

@tmeschter