Visual Studio Code C# Debugging Problem (The terminal process failed to launch: Path to shell executable "dotnet" is not a file of a symlink.)

Viewed 12023

I created a workspace using dotnet new console, wrote some code. But when I try to start debugging it using the option Run/Start debugging in visual studio code, it fails with the message:

Executing task: dotnet build /home/MY USERNAME/Desktop/Codes/C#/Console/Console.csproj /property:GenerateFullPaths=true /consoleloggerparameters:NoSummary
The terminal process failed to launch: Path to shell executable "dotnet" is not a file of a symlink.
Terminal will be reused by tasks, press any key to close it.

Using the dotnet run command in terminal works fine without any problems. But using the start debugging option fails for some reason. I really don't want to have to type this command every time I want to start the program.

Here is the result of dotnet --info command:

.NET Core SDK (reflects global.json if exists):\
 Version:   3.1.302\
 Commit:    41faccf259

Runtime Environment:\
 OS Name:     ubuntu\
 OS Version:  20.04\
 OS Platform: Linux\
 RID:         linux-x64\
 Base Path:   /usr/share/dotnet/sdk/3.1.302/

Host (useful for support):\
  Version: 3.1.6\
  Commit:  3acd9b0cd1

.NET Core SDKs installed:\
  3.1.302 [/usr/share/dotnet/sdk]

.NET Core runtimes installed:\
  Microsoft.AspNetCore.App 3.1.6 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]\
  Microsoft.NETCore.App 3.1.6 [/usr/share/dotnet/shared/Microsoft.NETCore.App]

To install additional .NET Core runtimes or SDKs:\
  https://aka.ms/dotnet-download

I've done some translating with the result, it may not match entirely the original output

13 Answers

Seems like this post isn't going to be answered. I've found a way to solve it. In "tasks.json" file i replaced the command "dotnet" with "/usr/bin/dotnet" and it's working fine now. But i think that the actual problem has something to do with the path variable and my solution is just a temporary one.

try deleting the .vscode folder from the dotnet root project. Then restart the vscode project window this .vscode folder will regenerate automatically while you are asked to add configuration. And now your c# debugging should be working fine. It worked for me on Linux.

This just randomly started happening on Mac for me. The fix was to add:

export dotnet=/usr/local/share/dotnet/dotnet

to my ~/.zshrc file. Then restart vscode.

Here the issue was the dotnet package had just been installed and added to the path on Mac (using .net 5.0). I had to exit vs-code, close the terminal I had launched it from using code . and then open a new terminal tab (where dotnet itself was resolvable) and then relaunch vs-code from that new terminal.

TLDR launch new terminal after dotnet install then use code . to launch new vs code instance from there (assumes you used the Ctrl/Cmd+shift+p "Add to shell" option in vscode to launch from a terminal)

In [LINUX] the $PATH environment variable may have another path to the "dotnet" command. So, you can use "echo $PATH" command to check it. If it's true, then you can check the bash file "sudo nano /etc/bash.bashrc" and remove the export with "dotnet" note.

Uninstalling dotnet and vscode did not work for me, nor did removing ~/.vscode

Eventually I resolved the issue by removing this directory ~/.config/Code. That directory contains various settings so you may wish to back it up / you may wish to retain your settings.json file.

There is probably a specific value somewhere in that directory that causes this particular issue but I didn't want to sift through it to find the culprit - probably easier to just start again.

The solution may be that you installed .NET using the default instructions using export DOTNET_ROOT etc, and putting that in ~/bashrc
The best way is, to install .NET SDK using

sudo apt install 
sudo apt-get update; \
sudo apt-get install -y apt-transport-https && \
sudo apt-get update && \
sudo apt-get install -y dotnet-sdk-5.0

Full instructions on https://docs.microsoft.com/en-us/dotnet/core/install/linux-ubuntu.

Now, .net install will indeed involve a 'symlink' about which the debugger complained. It should work.

I deleted the "dotnet" folder from my personal folder and it worked. Apparently, when I downloaded the SDK, I made a mistake.

Make the following changes in the settings.json file (typically in ~/.config/Code/User dir).

{
    "terminal.integrated.profiles.linux": {
       "bash" : { 
           "path" : "/bin/bash", 
           "icon" : "terminal-bash"
          }
        }
}

PS: Using Ubuntu 20.04. Neither removing ~/.config/Code nor removing ~/.vscode worked for me.

Old post but may help somebody:

I have had this issue when VScode is re-launched after a restart of my mac. Closing vscode and re-opening it gives access back to the shell.

To anyone else having this issue, you are likely experiencing a bug with VSCode, which will hopefully be resolved soon: https://github.com/microsoft/vscode/pull/158666

You likely have a ~/dotnet folder, and if your vscode process starts in the home directory, the folder will take priority over the executable in PATH.

Check the other answers for temporary workarounds until the fix is merged.

EDIT:

Just because there is so much conflicting information here, the fixes that should work are:

  • Changing the "command" field in tasks.json from "dotnet" to the full path (e.g. "/usr/bin/dotnet")

Or

  • Starting vscode via a terminal using code . (as long as you run this in a directory which doesn't contain a dotnet sub-directory)
Related