12

I'm installing dotnet core on Linux ARM64 using tarball as explained here. After installing I followed the suggestion to set DOTNET_ROOT=$PATH:$HOME/dotnet. However global tools fail with A fatal error occurred, the required library libhostfxr.so could not be found.

I fixed by changing the env variable to DOTNET_ROOT=$HOME/dotnet.

Is this a bug in the docs ?

5 Answers 5

13

Yes, this appears to be a bug in the documentation. The code which interprets DOTNET_ROOT does not split the string on :. DOTNET_ROOT should be set to an absolute file path which points to the directory containing the dotnet executable. If dotnet is on your PATH already, you can set it like this in bash/zsh.

export DOTNET_ROOT="$(dirname $(which dotnet))"

Or, if you care about symlinks:

export DOTNET_ROOT="$(dirname $(realpath $(which dotnet)))"
Sign up to request clarification or add additional context in comments.

Comments

4

came across this problem while working on porting .net libraries from Windows to Raspberry PI. On the Raspberry the .net core 3.1 installs in /opt/dotnet, and that's where DOTNET_ROOT ought to point at:

export DOTNET_ROOT="/opt/dotnet"

This should eliminate the "fatal error occurred. The required library libhostfxr.so could not be found." error when attempting to run portable code using the 'dotnet' command on the RPI

Comments

2

I was getting an error trying to execute the dotnet ef from the EF cli global tools install.

Added this to the bottom of my /home/<user>/.bashrc worked for me.

# User specific aliases and functions
export DOTNET_ROOT=$HOME/.dotnet
export PATH=$PATH:$DOTNET_ROOT:$DOTNET_ROOT/tools

Then the dotnet ef command worked correctly.

enter image description here

Comments

1

I had to add this to my ~/.zshrc

export DOTNET_ROOT=~/.dotnet
export PATH=$PATH:$DOTNET_ROOT

Comments

0

I found that I had different locations for different sdk/runtime versions. One was installed at "/home/{username}/.dotnet" and the other at "/usr/share/dotnet".

I found a post stating the default DOTNET_ROOT is "/usr/share/dotnet" and errors showed dotnet command was executing this location. I copied all files from "home/{username}/.dotnet" to "/usr/share/dotnet" with rsync.

sudo apt install rsync;
sudo rsync -a /home/{username}/.dotnet/ /usr/share/dotnet

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.