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

[BUG] Cannot correctly locate dotnet (Linux) #637

Open
uldahlalex opened this issue Oct 18, 2023 · 17 comments
Open

[BUG] Cannot correctly locate dotnet (Linux) #637

uldahlalex opened this issue Oct 18, 2023 · 17 comments
Labels
area-solution Solution explorer bug Something isn't working linux Linux

Comments

@uldahlalex
Copy link

Describe the Issue

When i run whereis dotnet, i get the expected output path:
/home/alex/dotnet/dotnet

However, C# Dev Kit reports the following:

No installed .NET SDK was found on the computer. If it is installed, make sure it can be found through the PATH environment variable. C# Dev Kit does not work without a supported version of SDK. After installing the SDK, you need restart the VS Code session, or the computer.

Furhtermore, the CodeAnalysis.LanguageServer attempts to search in the wrong directory, and there does not seem to be a way to guide it to the right one: Microsoft.CodeAnalysis.LanguageServer client: couldn't create connection to server.
Error: Cannot find dotnet path '/home/alex/dotnet/dotnet/dotnet'

Steps To Reproduce

  1. Installed vscode through AUR
  2. Attempted with both .NET 7 and 8 using official installation instructions (and I can use .NET CLI as expected)
  3. The only extensions I have installed are C# Dev Kit extensions
  4. The issue arises anytime I open a .NET repository, so it at least correctly assesses that it should be using the extension.

Expected Behavior

I expected the SDK to be available. Running dotnet --info in the vscode terminal works fine.

Environment Information

Arch Linux
Vscode 1.83.1
C# Dev Kit 1.0.4

@uldahlalex uldahlalex added the bug Something isn't working label Oct 18, 2023
@webreidi webreidi added linux Linux area-project Project load, Solution Explorer labels Oct 19, 2023
@tmeschter
Copy link
Member

@uldahlalex Can you provide the following additional information:

  1. The output of dotnet --info from the command line.
  2. Any output to the "Projects" pane of the VS Code Output window when this issue occurs.

Thank you!

@tmeschter tmeschter added the needs-more-info Needing more information, waiting on OP label Oct 19, 2023
@uldahlalex
Copy link
Author

@uldahlalex Can you provide the following additional information:

  1. The output of dotnet --info from the command line.
  2. Any output to the "Projects" pane of the VS Code Output window when this issue occurs.

Thank you!

Sure!
1)
dotnet --info
.NET SDK:
Version: 8.0.100-rc.2.23502.2
Commit: 0abacfc2b6

Runtime Environment:
OS Name: arch
OS Version:
OS Platform: Linux
RID: linux-x64
Base Path: /home/alex/dotnet/sdk/8.0.100-rc.2.23502.2/

.NET workloads installed:
There are no installed workloads to display.

Host:
Version: 8.0.0-rc.2.23479.6
Architecture: x64
Commit: 0b25e38ad3

.NET SDKs installed:
8.0.100-rc.2.23502.2 [/home/alex/dotnet/sdk]

.NET runtimes installed:
Microsoft.AspNetCore.App 8.0.0-rc.2.23480.2 [/home/alex/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 8.0.0-rc.2.23479.6 [/home/alex/dotnet/shared/Microsoft.NETCore.App]

Other architectures found:
None

Environment variables:
DOTNET_ROOT [/home/alex/dotnet]

global.json file:
Not found

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

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

  1. I do get a solution overview showing the .csproj projects. However, when I expand the project, I get the message that no .NET SDK is found.

@tmeschter
Copy link
Member

@uldahlalex For number 2, I was referring to this window rather than the Solution Explorer:
image

@uldahlalex
Copy link
Author

@tmeschter My apologies! Here is the output:

[Error - 20:05:17] Microsoft.CodeAnalysis.LanguageServer client: couldn't create connection to server.
Error: Cannot find dotnet path '/home/alex/dotnet/dotnet/dotnet'
at t.DotnetRuntimeExtensionResolver. (/home/alex/.vscode/extensions/ms-dotnettools.csharp-2.7.25-linux-x64/dist/extension.js:2:1429720)
at Generator.next ()
at /home/alex/.vscode/extensions/ms-dotnettools.csharp-2.7.25-linux-x64/dist/extension.js:2:1428897
at new Promise ()
at r (/home/alex/.vscode/extensions/ms-dotnettools.csharp-2.7.25-linux-x64/dist/extension.js:2:1428642)
at t.DotnetRuntimeExtensionResolver.getHostExecutableInfo (/home/alex/.vscode/extensions/ms-dotnettools.csharp-2.7.25-linux-x64/dist/extension.js:2:1429348)
at L. (/home/alex/.vscode/extensions/ms-dotnettools.csharp-2.7.25-linux-x64/dist/extension.js:2:1450068)
at Generator.next ()
at /home/alex/.vscode/extensions/ms-dotnettools.csharp-2.7.25-linux-x64/dist/extension.js:2:1443054
at new Promise ()
at r (/home/alex/.vscode/extensions/ms-dotnettools.csharp-2.7.25-linux-x64/dist/extension.js:2:1442799)
at L.startServer (/home/alex/.vscode/extensions/ms-dotnettools.csharp-2.7.25-linux-x64/dist/extension.js:2:1450011)
at L. (/home/alex/.vscode/extensions/ms-dotnettools.csharp-2.7.25-linux-x64/dist/extension.js:2:1445816)
at Generator.next ()
at /home/alex/.vscode/extensions/ms-dotnettools.csharp-2.7.25-linux-x64/dist/extension.js:2:1443054
at new Promise ()
at r (/home/alex/.vscode/extensions/ms-dotnettools.csharp-2.7.25-linux-x64/dist/extension.js:2:1442799)
at /home/alex/.vscode/extensions/ms-dotnettools.csharp-2.7.25-linux-x64/dist/extension.js:2:1445764
at s.createMessageTransports (/home/alex/.vscode/extensions/ms-dotnettools.csharp-2.7.25-linux-x64/dist/extension.js:2:2466546)
at s.createConnection (/home/alex/.vscode/extensions/ms-dotnettools.csharp-2.7.25-linux-x64/dist/extension.js:2:2306608)
at s.start (/home/alex/.vscode/extensions/ms-dotnettools.csharp-2.7.25-linux-x64/dist/extension.js:2:2297123)
at L. (/home/alex/.vscode/extensions/ms-dotnettools.csharp-2.7.25-linux-x64/dist/extension.js:2:1445915)
at Generator.next ()
at /home/alex/.vscode/extensions/ms-dotnettools.csharp-2.7.25-linux-x64/dist/extension.js:2:1443054
at new Promise ()
at r (/home/alex/.vscode/extensions/ms-dotnettools.csharp-2.7.25-linux-x64/dist/extension.js:2:1442799)
at L.initializeAsync (/home/alex/.vscode/extensions/ms-dotnettools.csharp-2.7.25-linux-x64/dist/extension.js:2:1445317)
at /home/alex/.vscode/extensions/ms-dotnettools.csharp-2.7.25-linux-x64/dist/extension.js:2:1458353
at Generator.next ()
at /home/alex/.vscode/extensions/ms-dotnettools.csharp-2.7.25-linux-x64/dist/extension.js:2:1443054
at new Promise ()
at r (/home/alex/.vscode/extensions/ms-dotnettools.csharp-2.7.25-linux-x64/dist/extension.js:2:1442799)
at t.activateRoslynLanguageServer (/home/alex/.vscode/extensions/ms-dotnettools.csharp-2.7.25-linux-x64/dist/extension.js:2:1457673)
at /home/alex/.vscode/extensions/ms-dotnettools.csharp-2.7.25-linux-x64/dist/extension.js:2:1476282
at Generator.next ()
at s (/home/alex/.vscode/extensions/ms-dotnettools.csharp-2.7.25-linux-x64/dist/extension.js:2:1471551)

@tmeschter
Copy link
Member

@uldahlalex Is that from the "Projects" output, or the "C#" output? The "Projects" output would be the useful one.

@uldahlalex
Copy link
Author

@tmeschter
image
This is the outputs I can choose between.

The output of the C# Dev Kit option in the dropdown is:

Starting Spawn .NET server...
Starting Open a solution...
Starting Open a solution with environment service...
Starting Clear environment...
Using local .NET runtime at "/home/alex/.config/Code/User/globalStorage/ms-dotnettools.vscode-dotnet-runtime/.dotnet/7.0.13~x64/dotnet"
.NET server started and IPC established in 1452ms
Completed Spawn .NET server (2804ms)
Completed Clear environment (3222ms)
Completed Open a solution with environment service (3433ms)
Starting Restore solution...
Completed Open a solution (3453ms)
Starting NuGet restore for the solution.
Starting command: "dotnet" restore /home/alex/source/apis/api/api.sln --interactive...
[object Object]
[object Object]

@tmeschter
Copy link
Member

@uldahlalex Ah, ok. Knowing that we didn't even get far enough to create the Projects output pane is helpful. Thank you!

@tmeschter tmeschter added area-solution Solution explorer and removed area-project Project load, Solution Explorer needs-more-info Needing more information, waiting on OP labels Oct 26, 2023
@tmeschter
Copy link
Member

@lifengl Are you aware of any issues locating the SDK on Linux?

@arafth
Copy link

arafth commented Oct 28, 2023

Same issue for me.
Tried on Manjaro Linux.
Regularly working with Rider with .Net 7.
Even dotnet --info on the terminal detects the SDKs.

Note that I have multiple SDKs installed. Tried with a single SDK also doesn't work.

@runette
Copy link

runette commented Nov 14, 2023

I am having this problem on MacOS as well.

It is very annoying.

At the very least - could you give us an option to explicitly tell it where dotnet is!

@LiveGood
Copy link

LiveGood commented Nov 28, 2023

Here is a workaround I found. I have tested this in Ubuntu 22.04
I have multiple SDKs installed with the dotnet-install.sh script
DOTNET_ROOT=/home/user/.local/share/.dotnet
Installed in this way which returns:
Screenshot from 2023-11-28 22-30-56
In order to make the solution explorer work, I installed duplicate version of .NET 8.0 through the apt package manager.
To do this I added the Microsoft repository following this documentation
Then I installed latest dotnet like this:
sudo apt-get install -y dotnet-sdk-8.0
This installs dotnet and if it's loaded first in the path which returns:
Screenshot from 2023-11-28 22-28-19
After that I must make sure that the the initial DOTNET_ROOT is found first in the path.

Essentially what happens is that, the solution explorer in VS Code works fine because it finds the /usr/bin/dotnet installation
On the other hand, the integrated terminal works with the version which is ACTUALLY found first in the path.
Screenshot from 2023-11-28 22-39-28

It took me a couple of hours to find this workaround. Their should be an explicit way to tell C# DevKit which installation of .NET to use.

Copy link

github-actions bot commented Apr 3, 2024

This issue has been marked as stale after 14 days of inactivity. @[ @ @], could you please take a look?

@runette
Copy link

runette commented Apr 4, 2024

It says so much about MS that issues are deleted because of inactivity rather than escalated because of inactivity!

@n00j
Copy link

n00j commented Apr 29, 2024

I'm experiencing the same bug as this. I couldn't replicate it exactly in a repo, but got a similar issue with this:
https://github.com/n00j/dotnetdevkitbug in a devcontainer

I have installed the SDK manually in my home folder
/home/agupta5/.dotnet

In my settings.json for vscode:

...
    "omnisharp.dotNetCliPaths": [
        "/home/agupta5/.dotnet/dotnet"
    ],
    "dotnet.dotnetPath": "/home/agupta5/.dotnet",
    "dotnetAcquisitionExtension.existingDotnetPath": [
        {
            "extensionId": "ms-dotnettools.csdevkit",
            "path": "/home/agupta5/.dotnet/dotnet"
        },
        {
            "extensionId": "ms-dotnettools.csharp",
            "path": "/home/agupta5/.dotnet/dotnet"
        },
        {
            "extensionId": "ms-dotnettools.vscode-dotnet-runtime",
            "path": "/home/agupta5/.dotnet/dotnet"
        },
        {
            "extensionId": "ms-dotnettools.vscodeintellicode-csharp",
            "path": "/home/agupta5/.dotnet/dotnet"
        }
    ],
...

The extension runs fine, but the solution explorer says
One or more errors occured. (No installed .NET SDK was found on the computer. If it is installed, make sure it can be found through the PATH environment variable.
solution_explorer

The SDK was installed via this guide: https://learn.microsoft.com/en-us/dotnet/core/install/linux-scripted-manual

wget https://dot.net/v1/dotnet-install.sh -O dotnet-install.sh
chmod +x ./dotnet-install.sh
./dotnet-install.sh --install-dir ~/.dotnet --version latest
./dotnet-install.sh --install-dir ~/.dotnet --channel 7.0 --version latest
./dotnet-install.sh --install-dir ~/.dotnet --channel 6.0 --version latest

and the is not dotnet installed on the machine in the default location.

I encountered this error via Remote-SSH. I don't seem to be able to replicate this via a devcontainer. Maybe the PATH variable is not being set in the shell that vscode-server is running in properly? In the devcontainer the solution loads correctly, but right-clicking on the project -> Debug -> start new instance returns in the missing sdk error:

------------------------------------------------------------------------------
You may only use the Microsoft Visual Studio .NET/C/C++ Debugger (vsdbg) with
Visual Studio Code, Visual Studio or Visual Studio for Mac software to help you
develop and test your applications.
------------------------------------------------------------------------------
You must install .NET to run this application.

App: /workspaces/replicate/bin/Debug/net8.0/dotnettest
Architecture: x64
App host version: 8.0.4
.NET location: Not found
...

If I then install the sdk in the default location: apt-get install dotnet8, the debugger then starts working.

@nagilson nagilson removed the area-sdk label Jul 30, 2024
@nagilson
Copy link
Member

@lifengl May you take a look at @tmeschter's question above?

Thank you @LiveGood for providing a workaround. There is actually a setting you can use to tell it which runtime to use, which the other individual points to above. The PATH setting is what takes precedence over this, so if you can set the PATH, that .NET Install will be used.

@archer884
Copy link

archer884 commented Jul 31, 2024

Edit:

My previous comments were wrong. The only fix for this on my computers has been to open my editor from the command line.

@ReDarkTechnology
Copy link

I'm experiencing the same bug as this. I couldn't replicate it exactly in a repo, but got a similar issue with this: https://github.com/n00j/dotnetdevkitbug in a devcontainer

I have installed the SDK manually in my home folder /home/agupta5/.dotnet

In my settings.json for vscode:

...
"omnisharp.dotNetCliPaths": [
"/home/agupta5/.dotnet/dotnet"
],
"dotnet.dotnetPath": "/home/agupta5/.dotnet",
"dotnetAcquisitionExtension.existingDotnetPath": [
{
"extensionId": "ms-dotnettools.csdevkit",
"path": "/home/agupta5/.dotnet/dotnet"
},
{
"extensionId": "ms-dotnettools.csharp",
"path": "/home/agupta5/.dotnet/dotnet"
},
{
"extensionId": "ms-dotnettools.vscode-dotnet-runtime",
"path": "/home/agupta5/.dotnet/dotnet"
},
{
"extensionId": "ms-dotnettools.vscodeintellicode-csharp",
"path": "/home/agupta5/.dotnet/dotnet"
}
],
...
The extension runs fine, but the solution explorer says One or more errors occured. (No installed .NET SDK was found on the computer. If it is installed, make sure it can be found through the PATH environment variable. solution_explorer

The SDK was installed via this guide: https://learn.microsoft.com/en-us/dotnet/core/install/linux-scripted-manual

wget https://dot.net/v1/dotnet-install.sh -O dotnet-install.sh
chmod +x ./dotnet-install.sh
./dotnet-install.sh --install-dir ~/.dotnet --version latest
./dotnet-install.sh --install-dir ~/.dotnet --channel 7.0 --version latest
./dotnet-install.sh --install-dir ~/.dotnet --channel 6.0 --version latest

and the is not dotnet installed on the machine in the default location.

I encountered this error via Remote-SSH. I don't seem to be able to replicate this via a devcontainer. Maybe the PATH variable is not being set in the shell that vscode-server is running in properly? In the devcontainer the solution loads correctly, but right-clicking on the project -> Debug -> start new instance returns in the missing sdk error:

------------------------------------------------------------------------------
You may only use the Microsoft Visual Studio .NET/C/C++ Debugger (vsdbg) with
Visual Studio Code, Visual Studio or Visual Studio for Mac software to help you
develop and test your applications.
------------------------------------------------------------------------------
You must install .NET to run this application.

App: /workspaces/replicate/bin/Debug/net8.0/dotnettest
Architecture: x64
App host version: 8.0.4
.NET location: Not found
...

If I then install the sdk in the default location: apt-get install dotnet8, the debugger then starts working.

I figured that if someone installed dotnet using apt then using dotnet-install.sh, dotnet prioritizes the one installed from apt. Typing which dotnet returns /usr/bin/dotnet/

I tried just purging the dotnet installation from apt by doing sudo apt purge dotnet* to remove any PATH variables it might have set and restarting Visual Studio Code, assuming that this is already added into ~/.bashrc or ~/.bashprofile or whatever it is

export DOTNET_ROOT=$HOME/.dotnet
export PATH=$PATH:$DOTNET_ROOT:$DOTNET_ROOT/tools

After that I typed which dotnet again and now it's actually pointing at my ~/.dotnet/dotnet folder correctly, finally recognizing the dotnet I installed manually

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-solution Solution explorer bug Something isn't working linux Linux
Projects
None yet
Development

No branches or pull requests

10 participants