csharp-language-server icon indicating copy to clipboard operation
csharp-language-server copied to clipboard

You must install .NET to run this application.

Open asward opened this issue 4 months ago • 3 comments

When trying to start csharp-ls from the terminal I get the following error:

WARD-LAPTOP-ARCH ~  > csharp-ls                                                                                                                                                                  2025-08-30 14:10:12
You must install .NET to run this application.

App: /home/ward/.dotnet/tools/csharp-ls
Architecture: x64
App host version: 9.0.8
.NET location: Not found

Learn more:
https://aka.ms/dotnet/app-launch-failed

Download the .NET runtime:
https://aka.ms/dotnet-core-applaunch?missing_runtime=true&arch=x64&rid=linux-x64&os=arch&apphost_version=9.0.8
Failed to resolve libhostfxr.so [not found]. Error code: 0x80008083

This is a fairly new install of Arch linux, and the first time I'm installing dotnet in general. Have removed and reinstalled dotnet a few times.

Found a number of similar issues - most said adding the DOTNET_ROOT envvar fixed it. I tried a few over more convoluted things as well, to no avail.

WARD-LAPTOP-ARCH ~  > dotnet --info                                                                                                                                                              2025-08-30 14:19:43
.NET SDK:
 Version:           9.0.304
 Commit:            f12f5f689e
 Workload version:  9.0.300-manifests.70d87660
 MSBuild version:   17.14.16+5d8159c5f

Runtime Environment:
 OS Name:     arch
 OS Version:  
 OS Platform: Linux
 RID:         linux-x64
 Base Path:   /home/ward/.dotnet/sdk/9.0.304/

.NET workloads installed:
There are no installed workloads to display.
Configured to use loose manifests when installing new manifests.

Host:
  Version:      9.0.8
  Architecture: x64
  Commit:       aae90fa090

.NET SDKs installed:
  9.0.304 [/home/ward/.dotnet/sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 9.0.8 [/home/ward/.dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 9.0.8 [/home/ward/.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
WARD-LAPTOP-ARCH ~  > dotnet tool list --global                                                                                                                                                  2025-08-30 14:20:32
Package Id      Version      Commands 
--------------------------------------
csharp-ls       0.19.0       csharp-ls

WARD-LAPTOP-ARCH ~  > which dotnet                                                                                                                                                               2025-08-30 14:21:02
/home/ward/.dotnet/dotnet
WARD-LAPTOP-ARCH ~  > which csharp-ls                                                                                                                                                            2025-08-30 14:21:56
/home/ward/.dotnet/tools/csharp-ls
WARD-LAPTOP-ARCH ~  > echo $DOTNET_ROOT                                                                                                                                                          2025-08-30 14:21:59
/home/ward/.dotnet

asward avatar Aug 30 '25 21:08 asward

I don't think this is so much a csharp-ls issue but a dotnet issue. As you mentioned, there are loads of issues about this, most notably on the dotnet sdk repo itself. It seems to be the installation path, whenever it's not installed globally for the system but only for the user.

I hit this the other week on a fresh Windows server install, using the dotnet-install.ps1 script to install the runtimes. I had to get the DOTNET_ROOT environment variable to get my services running.

AdeAttwood avatar Sep 03 '25 09:09 AdeAttwood

You most likely followed the dotnet-install.sh method. This will only install dotnet for the current user ($HOME/.dotnet). This means that any global tools will use the DOTNET_ROOT env var, or /usr/share/dotnet by default for searching for the runtime.

I managed to replicate your issue on a fresh Arch install, but adding export DOTNET_ROOT=~/.dotnet to the ~/.bashrc did fix this issue. I'm guessing you just didn't export the variable, since that would mean that no subprocess has visibility of it.

I'd suggest just running ./dotnet-install.sh --install-dir /usr/share/dotnet -c STS -v latest to install it globally to avoid any other quirks

alsi-lawr avatar Sep 23 '25 13:09 alsi-lawr

I installed the sdk as in https://learn.microsoft.com/nb-no/dotnet/core/install/linux-ubuntu-install?tabs=dotnet9&pivots=os-linux-ubuntu-2404 which puts them in /usr/share/dotnet then I installed csharp-ls as in this readme with dotnet tool install --global csharp-ls and I got an error like the above.

I fixed it with

export DOTNET_ROOT=/usr/share/dotnet

(or (setenv "DOTNET_ROOT" "/usr/share/dotnet") in ~/emacs.d/init.el)

Maybe the README should mention that you can set DOTNET_ROOT if it can't find it? Or TROUBLESHOOTING.md

unhammer avatar Dec 12 '25 13:12 unhammer