runtime: Running a .NET 5 project on macOS M1 with .NET 6 leads to confusing error message
Steps to reproduce:
-
Install .NET 6 RC1 on an M1 Mac with the ARM64 architecture. Make sure there are no previous installs of .NET.
.NET SDK (reflecting any global.json): Version: 6.0.100-rc.1.21458.32 Commit: d7c22323c4 Runtime Environment: OS Name: Mac OS X OS Version: 12.0 OS Platform: Darwin RID: osx-arm64 Base Path: /usr/local/share/dotnet/sdk/6.0.100-rc.1.21458.32/ Host (useful for support): Version: 6.0.0-rc.1.21451.13 Commit: d7619cd4b1 .NET SDKs installed: 6.0.100-rc.1.21458.32 [/usr/local/share/dotnet/sdk] .NET runtimes installed: Microsoft.AspNetCore.App 6.0.0-rc.1.21452.15 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.NETCore.App 6.0.0-rc.1.21451.13 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] -
Try to run a .NET application that targets .NET 5 with
dotnet runYou’ll get output that looks like:Failed to load /usr/local/share/dotnet/host/fxr/6.0.0-rc.1.21451.13/libhostfxr.dylib, error: dlopen(/usr/local/share/dotnet/host/fxr/6.0.0-rc.1.21451.13/libhostfxr.dylib, 0x0001): tried: '/usr/local/share/dotnet/host/fxr/6.0.0-rc.1.21451.13/libhostfxr.dylib' (mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64')), '/usr/local/lib/libhostfxr.dylib' (no such file), '/usr/lib/libhostfxr.dylib' (no such file) The library libhostfxr.dylib was found, but loading it from /usr/local/share/dotnet/host/fxr/6.0.0-rc.1.21451.13/libhostfxr.dylib failed - Installing .NET prerequisites might help resolve this problem. https://go.microsoft.com/fwlink/?linkid=2063366
I would expect to see a better error message, either indicating that .NET 5 is not installed, or that an available SDK/runtime is not available.
Interestingly enough, even with a rollForward policy of major, it still fails with the same error message.
global.json:
{
"sdk": {
"allowPrerelease": true,
"rollForward": "major"
}
}
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 62 (40 by maintainers)
Ugh, got my x64 and arm64 copy screwed up again. I get a slightly different, but still not great error message, because I have
/etc/dotnet/install_locationset up for how it should be after the installer is fixed (pointing to an empty x64 subdirectory).My error message is:
Unfortunately this is still very misleading.
@agocke It does. The exact project I am using is here: https://gist.github.com/vcsjones/1fef26b5a9ad4bfe934425b272d56797
dotnet buildsucceeds.dotnet runfails.The
dotnet --infooutput is the same as in the initial issue comment.@vitek-karas After I have redone the whole installation steps again and found what works and what doesn’t. Below is what I did to make it mostly work.
netcoreapp3.1netcoreapp3.1andnet5.0dotnet --infostill shows all three versions of SDKs and Runtimes 3.1 and 5.0 stopped working. SDK 3.1.408 and SDK 5.0.402 were wiped up from/usr/local/share/dotent/usr/local/share/dotent/x64folder doesn’t exist/usr/local/share/dotent/x64folder showed up. SDK 3.1.415 and SDK 5.0.403 appeared in x64 folderdotnetcreated by SDK 6.0.10 got wiped up and disappeared from/usr/local/share/dotnet/usr/local/share/dotnetdotnet --infoshows SDK 3.1.408 Rtm 3.1.14 SDK 5.0.402 Rtm 5.0.11 These are older versions I installed (Steps 1 & 2) but got wiped up during 6.0 installationSystem.Runtime.InteropServices.RuntimeInformation.FrameworkDescriptioncaptures different runtimes: Rtm 3.1.21 and Rtm 5.0.12 I installed these after 6.0 installation wiped up my previous SDK/Runtimedotnet runworks well withnetcoreapp3.1,net5.0,net6.0dotnet publishworks well withnetcoreapp3.1,net5.0,net6.0dotnet {appname}.dllworks well withnet6.0dotnet {appname}.dlldoes NOT work withnetcoreapp3.1ornet5.0/usr/local/share/dotnet/x64/dotnet {appname}.dllworks withnetcoreapp3.1ornet5.0The tricky parts are misleading
dotnet --infoand Step 15. Otherwise, this setting works for me. Happy new year.I just bumped the TFM but I will admit I wasted a bit of time getting detoured by this. I don’t really expect it to work now that I understand what is happening, but it took a while to get there. I only called out rollForward because I would expect that to work. Why would it load the .NET 5 AppHost if I should be rolling forward to 6? (Keep in mind I have a very naive understanding with how this works).
Here are the events that led to this:
dotnet runitotool -vhinstead of looking at more obvious things.dotnet newdotnet newmade the project with a .NET 6 TFM. Is that it?My hope is that at least this error path can have better output for folks.
Here are the “instructions” on how to configure your machine today.
https://github.com/dotnet/sdk/issues/20584