X Tool on Apple ARM MACs

I experience a strange problem with the X tool on dotnet 6 on Macs with an Apple Silicon M1 / M2 processor. This does NOT happen on Intel MACs.

So here is the problem (X seems not to find the installed SDK):

[tools] x
You must install .NET to run this application.

App: /Users/tbednarz/.dotnet/tools/x
Architecture: x64
App host version: 7.0.2
.NET location: Not found

Learn about runtime installation:
https://aka.ms/dotnet/app-launch-failed

Download the .NET runtime:
https://aka.ms/dotnet-core-applaunch?missing_runtime=true&arch=x64&rid=osx.13-x64&apphost_version=7.0.2

I run .NET6 on the MAC:

[tools] dotnet --info
.NET SDK:
 Version:   6.0.401
 Commit:    0906eae6f8

Laufzeitumgebung:
 OS Name:     Mac OS X
 OS Version:  13.1
 OS Platform: Darwin
 RID:         osx-arm64
 Base Path:   /usr/local/share/dotnet/sdk/6.0.401/

global.json file:
  Not found

Host:
  Version:      6.0.9
  Architecture: arm64
  Commit:       163a63591c

.NET SDKs installed:
  6.0.401 [/usr/local/share/dotnet/sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 6.0.9 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 6.0.9 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]

Download .NET:
  https://aka.ms/dotnet-download

Learn about .NET Runtimes and SDKs:
  https://aka.ms/dotnet/runtimes-sdk-info
[tools]

And in my PATH I have both, the SDK and the TOOLS:

[tools] echo $PATH
/opt/homebrew/bin:/opt/homebrew/sbin:/Users/tbednarz/.dotnet/tools:/opt/homebrew/bin:/opt/homebrew/sbin:/Library/Frameworks/Python.framework/Versions/3.10/bin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/share/dotnet:~/.dotnet/tools:/Library/Apple/usr/bin:/Users/tbednarz/Library/Application Support/JetBrains/Toolbox/scripts

Interesting is, that the path to tools appears twice, once expanded and once with the ~ for the home folder. This sometimes does not work correctly. So I added the expanded tools path in my .zshrc file. I do NOT know where the other one is coming from, I did not set it.

Does anybody have some experience with the apple silicon macs and how to get the x tool working?

Did you follow the Apple M1 instructions to install the x dotnet tool?

Install on Apple’s new M1 Pro and M1 Max ARM chips with:

$ dotnet tool install -g -a x64 x

Yes of course, I didn’t miss the -a architecture parameter. Installation also worked without error.

To me it looks like the x tool is not parsing the path correctly, at least thats what the error message implies. It should find /usr/local/share/dotnet where the executable dotnet file is stored. I can call dotnet in every shell and its being found immediately.

Please have a look at the following two statements:

[dotnet] dotnet tool list
Paket-ID      Version      Befehle      Manifest
------------------------------------------------
[dotnet] dotnet tool install -g -a x64 x
Das Tool "x" ist bereits installiert.

list does not show any installed tool but if I try to (re-)install x it says it is already installed. That is very strange but looks to me like a path problem somewhere… The two commands seem to look in different places.

The management of tool paths are handled by dotnet SDK, not by individual tools.

We don’t have access to M1 to test, but looking at this reddit thread you may need to use the x64 dotnet binary to install x64 dotnet tools (/usr/local/share/dotnet/x64/dotnet).

`

Such a problem was described here. But in my /etc/dotnet folder are the correct files and they contain correct paths:

[dotnet] pwd
/etc/dotnet
[dotnet] ll
total 16
-rw-r--r--  1 root  wheel    28B  6 Okt 10:10 install_location
-rw-r--r--  1 root  wheel    24B  6 Okt 10:10 install_location_arm64
[dotnet] cat install_location
/usr/local/share/dotnet/x64
[dotnet] cat install_location_arm64
/usr/local/share/dotnet
[dotnet]

My dotnet --info also shows, that I am using a plain arm64 version of the dotnet 6 SDK. I can also run and debug my servers correctly using the latest version of JetBrains Rider.

So I was just reviewing your documentation where you write for M1 Macs:

dotnet tool install -g -a x64 x which seems to force the use of Rosetta.

This leads me to the question: Do you need to build the x tool architecture specific (arm64 / X64)?

And Rosetta is not the best option to use (it is like an emulator), and I am pretty sure it does not work well if you mix arm64 SDK with X64 code, e.g. loading DLLs built for X64. According to my /etc/hosts folder, arm64 seems to be the correct default architecture.

So if you need arm64 builds and do not have a Mac with M1 or M2 chips, let me know if I can be of any help. I have an M2 MacBook Air and an MacStudio with M1 Ultra chip and tons of RAM beside my intel based Macs.

No the x tool is not architecture specific, someone else reported installing it x64 is what they needed to get it running on M1.

If you would like to build a local version of the X tool the source code is available at GitHub - ServiceStack/dotnet-app: ServiceStack app and web tools for developing ServiceStack's .NET Core Web Apps with the X.csproj project used to build the x tool. We build it from ServiceStack Sources so it also requires checking out GitHub - ServiceStack/ServiceStack: Thoughtfully architected, obscenely fast, thoroughly enjoyable web services for all along side it.

@mythz: OK I think you should update your documentation.
If you have a plain vanilla arm64 SDK installation on a MAC with M1 or M2 processor, you can run the same command as on Intel Macs (or Linux or Windows):

dotnet tool install --global x

Now one can call x without any error. However for whatever reasons, dotnet tool list does not show x in the list.

[~] dotnet tool list
Paket-ID      Version      Befehle      Manifest
------------------------------------------------
[~]

But x seems to work:

[~] x

Version:  6.0.9

Usage:

  x new                      List available Project Templates
  x new <template> <name>    Create New Project From Template
  x download <user>/<repo>   Download latest GitHub Repo Release
  x get <url>                Download URL to file                     (-out <file|dir>)
  x stream <url>             Stream URL contents to console stdout

...etc

The -a x64 option may be required for SDKs prior to V6 (including Core 3.1) since these require Rosetta (Dont know if that was working sometime in the past). But SDKs V6 and later can be downloaded as plain vanilla arm64 builds.