Dotnet-script, libhostfxr.so not found

When I run dotnet-script, I get this error:

dotnet-script
A fatal error occurred. The required library libhostfxr.so could not be found.
If this is a self-contained application, that library should exist in [/home/b0ef/.dotnet/tools/.store/dotnet-script/1.3.1/dotnet-script/1.3.1/tools/net6.0/any/].
If this is a framework-dependent application, install the runtime in the global location [/usr/share/dotnet] or use the DOTNET_ROOT environment variable to specify the runtime location or register the runtime location in [/etc/dotnet].

The .NET runtime can be found at:
  - https://aka.ms/dotnet-core-applaunch?missing_runtime=true&arch=x64&rid=nixos.22.05-x64&apphost_version=6.0.5

This seems to be a known issue and listed here as resolved:

https://github.com/NixOS/nixpkgs/pull/170296

It says it’s merged into master on April 26th, so this should’ve been included in the channel I’m running, no?

b0ef $ ~ >
sudo nix-channel --list
[sudo] password for b0ef:
home-manager https://github.com/nix-community/home-manager/archive/release-22.05.tar.gz
nixos https://nixos.org/channels/nixos-22.05

No that change is not on stable.

ok, so master is basically head, but can I pull in that change without going to unstable?

Fork the repo, checkout stable, cherry-pick the commit, change your input to that, profit.

ok, this is far out, as I’ve started using nix like two weeks ago;) Anyways, I should focus on a flake?, like this: How do I apply a GitHub commit to my configuration.nix? - #3 by nrdxp

Oh, overread that you where still using channels. You can do that same thing with channels by adding a GitHub archive download link as as a new channel URL.

I wonder first if this commit is part of unstable, at this point? How can I check that?

It is in unstable when it was pushed by hydra to GitHub - NixOS/nixpkgs at nixos-unstable

Seems I’m wrong here, as that issue I linked to on Github is not the same issue I’m facing, so I’m back to square one.

b0ef $ ~ >
find /nix/store/3axaxgbragp3zhb20i2swfqdwdnl1b3v-dotnet-sdk-6.0.300/ -iname "*fxr*"
/nix/store/3axaxgbragp3zhb20i2swfqdwdnl1b3v-dotnet-sdk-6.0.300/host/fxr
/nix/store/3axaxgbragp3zhb20i2swfqdwdnl1b3v-dotnet-sdk-6.0.300/host/fxr/6.0.5/libhostfxr.so
/nix/store/3axaxgbragp3zhb20i2swfqdwdnl1b3v-dotnet-sdk-6.0.300/packs/Microsoft.NETCore.App.Host.linux-x64/6.0.5/runtimes/linux-x64/native/hostfxr.h

ok, it works if I do this:

export DOTNET_ROOT=/nix/store/3axaxgbragp3zhb20i2swfqdwdnl1b3v-dotnet-sdk-6.0.300/

, but shouldn’t this be set by the installation of dotnet?

I installed dotnet-script non declarative, though:

dotnet tool install -g dotnet-script

Maybe it should’ve been installed declaratively? If so, how?:wink:

Checkout my dotfiles. You need dotnet.nix and dotnet-tool.nix from it. I packed dotnet-script for you, so you just need to add dotnet-script in the list of tools in dotnet.nix.

Note that my declarative global tool installation is super-experimental.