sdk: M1 Mac cannot find libhostfxr.dylib

Describe the bug

I’m trying to port an app from .NET 5 to .NET 6 to support M1 Macs. I could build and publish the project fine, but when I start the app, I get the following error -

Failed to load 
 azuredatastudio/extensions/mssql/sqltoolsservice/OSX/3.0.0-release.129/libhostfxr.dylib, error: dlopen(azuredatastudio/extensions/mssql/sqltoolsservice/OSX/3.0.0-release.129/libhostfxr.dylib, 1): no suitable image found.  Did find:
 azuredatastudio/extensions/mssql/sqltoolsservice/OSX/3.0.0-release.129/libhostfxr.dylib: mach-o, but wrong architecture
 azuredatastudio/extensions/mssql/sqltoolsservice/OSX/3.0.0-release.129/libhostfxr.dylib: mach-o, but wrong architecture
The library libhostfxr.dylib was found, but loading it from 
 azuredatastudio/extensions/mssql/sqltoolsservice/OSX/3.0.0-release.129/libhostfxr.dylib failed
  - Installing .NET prerequisites might help resolve this problem.
     https://go.microsoft.com/fwlink/?linkid=2063366

I saw other similar issues, where this issue occurs when loading .NET 5 and 6 side by side, but I only have .NET 6 on this M1 machine.

To Reproduce

Exceptions (if any)

Further technical details

  • Include the output of dotnet --info
 .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:  11.6
 OS Platform: Darwin
 RID:         osx.11.0-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]

To install additional .NET runtimes or SDKs:
  https://aka.ms/dotnet-download
  • The IDE (VS / VS Code/ VS4Mac) you’re running on, and its version - VS Code for Mac (ARM64) - Big Sur 11.6
  • Result of running dotnet --list-sdks - 6.0.100-rc.1.21458.32 [/usr/local/share/dotnet/sdk]

About this issue

  • Original URL
  • State: open
  • Created 3 years ago
  • Reactions: 4
  • Comments: 17 (8 by maintainers)

Most upvoted comments

Awesome, this works. Would this be the official way or do you think the tool installer will be updated to detect the architecture?

dotnet tool install dotnet-ef --global -a arm64

I recommend trying this again once RC2 is available as we’ve made significant changes to our Mac installer behavior. CC @vitek-karas @ericstj to see if they agree that our rc2 changes will fix this.