apple silicone

Rune Søvsø Christensen 0 Reputation points
2024-07-26T09:55:48.3066667+00:00

While trying to follow the associate training I have reached the step where I have to actually create a project, https://learn.microsoft.com/en-us/training/modules/develop-azure-functions/5-create-function-visual-studio-code

Problem is that I run a macbook pro m1, and the output specifies that it cannot find an Intel cpu.

Here is the error

ailed to get latest templates: Command "dotnet '/Users/runeschristensen/.vscode/extensions/ms-azuretools.vscode-azurefunctions-1.15.1/resources/dotnetJsonCli/net6.0/Microsoft.TemplateEngine.JsonCli.dll' --templateDir '/Users/runeschristensen/Library/Application Support/Code/User/globalStorage/ms-azuretools.vscode-azurefunctions/~4/net8.0-isolated' --operation list" failed with exit code "130":
Failed to load /usr/local/share/dotnet/shared/Microsoft.NETCore.App/6.0.10/libhostpolicy.dylib, error: dlopen(/usr/local/share/dotnet/shared/Microsoft.NETCore.App/6.0.10/libhostpolicy.dylib, 0x0001): tried: '/usr/local/share/dotnet/shared/Microsoft.NETCore.App/6.0.10/libhostpolicy.dylib' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e' or 'arm64')), '/System/Volumes/Preboot/Cryptexes/OS/usr/local/share/dotnet/shared/Microsoft.NETCore.App/6.0.10/libhostpolicy.dylib' (no such file), '/usr/local/share/dotnet/shared/Microsoft.NETCore.App/6.0.10/libhostpolicy.dylib' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e' or 'arm64'))
An error occurred while loading required library libhostpolicy.dylib from [/usr/local/share/dotnet/shared/Microsoft.NETCore.App/6.0.10]
Azure Training
Azure Training
Azure: A cloud computing platform and infrastructure for building, deploying and managing applications and services through a worldwide network of Microsoft-managed datacenters.Training: Instruction to develop new skills.
1,725 questions
{count} votes

1 answer

Sort by: Most helpful
  1. RDash 2,155 Reputation points Microsoft Vendor
    2024-07-27T04:15:43.1133333+00:00

    Hi Rune Søvsø Christensen,

    The error you're encountering indicates a compatibility issue between the architecture of the .NET runtime you have installed and your machine's architecture. Specifically, it looks like you're trying to run an x86_64 (Intel) version of .NET on an arm64 (Apple Silicon) machine.

    Here are steps to resolve this issue:

    1. Install the Correct .NET SDK: Make sure you have the correct .NET SDK for your architecture. You can download the ARM64 version of the .NET SDK from the official Microsoft .NET download page.
       brew install --cask dotnet-sdk
    
    1. Verify Installation: Verify that the correct SDK is installed by running:
       dotnet --info
    

       This should show that the runtime and SDK are for ARM64 architecture.

    1. Update VS Code Extensions: Ensure that all your VS Code extensions, particularly the Azure Functions extension, are up-to-date.
    2. Use Rosetta 2: If you need to run x86_64 applications on your ARM64 machine, you can use Rosetta 2. To install Rosetta 2, run:
       softwareupdate --install-rosetta
    

       Then, you can run your terminal or VS Code in Rosetta mode by right-clicking the application in Finder, selecting "Get Info," and checking the "Open using Rosetta" option.

    1. Check Dockerfile Configuration: Ensure your Dockerfile is set up to use the correct architecture. If you're building a Docker image, specify the platform:
    FROM --platform=linux/arm64 mcr.microsoft.com/dotnet/aspnet:6.0 AS base
    
    1. Clear Local Cache: Sometimes, clearing the local cache can help resolve persistent issues. You can do this by deleting the globalStorage folder mentioned in the error message and then restarting VS Code:
     rm -rf "/Users/runeschristensen/Library/Application Support/Code/User/globalStorage/ms-azuretools.vscode-azurefunctions"
    

    After following these steps, try running your command again. This should resolve the architecture compatibility issue and allow you to proceed with your work.

    If you have further and issue, please don't hesitate to reach out to us if you have any further queries. I hope the information provided has been helpful to you! If so, please accept the answer by clicking the Accept Answer / Upvote on the post. We value your feedback, and it will help to assist others who might have a similar query. Thank you for your contribution in enhancing Microsoft Q&A!

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.