sdk: .NET tool does not seem to find the SDK

Hi. It may be not the best place, but here’s a problem/question. I’m trying to run fsautocomplete, a .NET tool, and getting

$ fsautocomplete 
You must install .NET to run this application.

App: /home/goose/.dotnet/tools/fsautocomplete
Architecture: x64
App host version: 7.0.0
.NET location: Not found

However, SDK exist:

$ dotnet --list-sdks
6.0.403 [/nix/store/4j4w9b1a9n54zmdrvfwhcsxgwsb3k1qq-dotnet-core-combined/sdk]
7.0.100 [/nix/store/4j4w9b1a9n54zmdrvfwhcsxgwsb3k1qq-dotnet-core-combined/sdk]

As well as runtimes:

$ dotnet --list-runtimes 
Microsoft.AspNetCore.App 6.0.11 [/nix/store/4j4w9b1a9n54zmdrvfwhcsxgwsb3k1qq-dotnet-core-combined/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 7.0.0 [/nix/store/4j4w9b1a9n54zmdrvfwhcsxgwsb3k1qq-dotnet-core-combined/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 6.0.11 [/nix/store/4j4w9b1a9n54zmdrvfwhcsxgwsb3k1qq-dotnet-core-combined/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 7.0.0 [/nix/store/4j4w9b1a9n54zmdrvfwhcsxgwsb3k1qq-dotnet-core-combined/shared/Microsoft.NETCore.App]

$DOTNET_ROOT is defined as well:

$ echo $DOTNET_ROOT
/nix/store/4j4w9b1a9n54zmdrvfwhcsxgwsb3k1qq-dotnet-core-combined

and points to the correct location.

Moreover, dotnet run works in a sample project. But the .net tool won’t start.

What other places or env paths do the nuget packages look for, besides $PATH and $DOTNET_ROOT?

About this issue

  • Original URL
  • State: open
  • Created a year ago
  • Reactions: 3
  • Comments: 18 (4 by maintainers)

Most upvoted comments

I do, the only thing that changed is my nixpkgs flake input. And as you can see above, dotnet --list-sdks even finds the SDK. It’s just dotnet format that fails.

Out of curiosity: Does dotnet format work for you? It started failing for me after I updated nix flake inputs (including .NET SDK):

No .NET SDKs were found.

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

Learn about SDK resolution:
https://aka.ms/dotnet/sdk-not-found
Unable to locate MSBuild. Ensure the .NET SDK was installed with the official installer.

With this SDK version dotnet format works fine for me:

❯ dotnet --list-sdks                                                                  
7.0.100 [/nix/store/6mwwnyxxq9j28vgnk7lknb7sgpvxfyn3-dotnet-core-combined/sdk]

And this is the version where it fails:

❯ dotnet --list-sdks      
7.0.102 [/nix/store/74942cgwzr715prs4wlqdhhd8kh75700-dotnet-core-combined/sdk]

I haven’t tried any versions in-between.

Ok so I did something, that both .NET and Nix people are gonna hate me for

But here’s what my fellow Nix people can do to use local fsautocomplete as a global tool

  fsautocomplete-drv =
    pkgs.fetchzip {
      url = "https://www.nuget.org/api/v2/package/fsautocomplete/0.58.4";
      sha256 = "sha256-PLO24n2zcRPWR6/ihAnCT2Y8kBH9WCHhlkOqc7xEujg=";
      extension = "zip";
      stripRoot = false;
    };

  fsautocomplete-fake = pkgs.writeScript "fsautocomplete-fake" "dotnet ${fsautocomplete-drv}/tools/net7.0/any/fsautocomplete.dll";

  fsautocomplete = pkgs.runCommand "fsautocomplete" {} ''
    mkdir $out
    ln -s ${fsautocomplete-fake} $out/fsautocomplete
  '';

  shellHook = ''
    PATH="${fsautocomplete}:$PATH";
  '';

(.NET SDK team on their way to eat me for that)