Reputation: 19184
While trying to add authentication to a .net core app on mac, using this command :
dotnet aspnet-codegenerator identity -h
I receive this error :
Macintosh-2:Website abd$ dotnet aspnet-codegenerator identity -h A fatal error occurred, the required library libhostfxr.dylib could not be found. If this is a self-contained application, that library should exist in [/Users/abd/.dotnet/tools/.store/dotnet-aspnet-codegenerator/2.2.3/dotnet-aspnet-codegenerator/2.2.3/tools/netcoreapp2.1/any/]. If this is a framework-dependent application, install the runtime in the default location [/usr/local/share/dotnet] or use the DOTNET_ROOT environment variable to specify the runtime location. M
Upvotes: 7
Views: 18244
Reputation: 3361
I was having the same problem (.Net SDK 7 on m1). Nothing worked for me until I figured out that target framework of my app was 3.1
and the 3.1 runtime does not exist in arm version. So SDK could build but could NOT start. Changed the target to be <TargetFramework>net7.0</TargetFramework>
and it works, as simple as that.
I think installing x86 version of framework would've also worked via Rosetta, but I would not pollute my machine to check this.
Upvotes: 3
Reputation: 453
This solved it for me:
dotnet tool uninstall dotnet-ef --global
dotnet tool install dotnet-ef --global -a arm64
Upvotes: 9
Reputation: 559
I ran into this same issue with running the Omnisharp language server on an M1 Mac. The solution for me was to set the DOTNET_ROOT
environment variable to the correct global dotnet location. For me this was /usr/local/share/dotnet
.
I also needed to update the contents of /etc/dotnet/install_location
. I noticed that there were two files in /etc/dotnet
.
install_location
install_location_arm64
The install_location_arm64
contained the correct path to dotnet (/usr/local/share/dotnet
), but install_location
contained /usr/local/share/dotnet/x64
which doesn't exist. After updating the contents of install_location
to /usr/local/share/dotnet
, the problem was solved for me.
Upvotes: 2
Reputation: 121
For Mac M1 processor, the .NET libraries are not located in the default install location "usr/local/share/dotnet"
; but rather in one of its sub-directories "./x64"
.
You have to set the DOTNET_ROOT
environment variable to point to that sub-directory.
export DOTNET_ROOT=/usr/local/share/dotnet/x64
I guess this same solution could be scaled beyond the M1 processor, so long you set DOTNET_ROOT to whatever directory contains libhostfxr.xx
Upvotes: 9
Reputation: 697
if you have installed/uninstalled .net frameworks on your machine maybe the links are looking in the wrong folder.
check dotnet location with the command which dotnet eg the location should be something like that: /usr/local/share/dotnet/dotnet
Afterwards, check the file /etc/dotnet/install_location should contain one line with the above path.
Upvotes: 0
Reputation: 736
Dotnet executable will be present at $DOTNET_ROOT which you can find with which dotnet
or
readlink $(which dotnet)
A successful dotnet installation will have the libhostfxr.dylib
file at $DOTNET_ROOT/host/fxr/$version/
If so, it is a permission issue and running with sudo will do.
sudo dotnet aspnet-codegenerator identity -h
Upvotes: 3