planetarium / libplanet

Blockchain in C#/.NET for on-chain, decentralized gaming
https://docs.libplanet.io/
GNU Lesser General Public License v2.1
510 stars 144 forks source link

@planetarium/cli: Support `arm64` CPU architecture for `planet` command #2280

Closed moreal closed 2 years ago

moreal commented 2 years ago

Currently, it shows the below error message when I ran npm install -g @planetarium/cli:

$ npm install -g @planetarium/cli 
npm ERR! code EBADPLATFORM
npm ERR! notsup Unsupported platform for @planetarium/cli@0.41.1: wanted {"os":"darwin,linux,win32","arch":"x64"} (current: {"os":"darwin","arch":"arm64"})
npm ERR! notsup Valid OS:    darwin,linux,win32
npm ERR! notsup Valid Arch:  x64
npm ERR! notsup Actual OS:   darwin
npm ERR! notsup Actual Arch: arm64

npm ERR! A complete log of this run can be found in:
longfin commented 2 years ago

I think that we may have to deal with it after #2161.

boscohyun commented 2 years ago

I had the same problem and solved it by installing another dotnet sdk version 3.1.x. My m1 mac has two versions of dotnet sdk.

BasixKOR commented 2 years ago

Workaround: Install .NET SDK 3.1, and install it by dotnet tool install -g Libplanet.Tools

dahlia commented 2 years ago

Although this issue (#2280) and #2161 are apparently duplicated, I'm going to distinguish two by their ways to reproduce their problems.

2161 is about the problem faced when you try dotnet build --project Libplanet.Tools or dotnet tool install Libplanet.Tools — it's about building Libplanet.Tools on arm64.

This issue (#2280), on the other hand, deals with the problem faced when you try the planet program from GitHub Releases or npm install @planetarium/cli — it's about how we provide official executable binaries of planet.

The key blocker of this as of September 2022 is that:

longfin commented 2 years ago

dotnet build does not support crosscompile osx-arm64 binaries from other hosts than osx-arm64.

I guess it's possible. The below log is from another .NET executable project built with the osx-arm64 on my linux-x64 machine.

[longfin@longfin-desktop-arch .Libplanet]$ dotnet --info
.NET SDK (reflecting any global.json):
 Version:   6.0.109
 Commit:    58a93139d8

Runtime Environment:
 OS Name:     arch
 OS Version:  
 OS Platform: Linux
 RID:         arch-x64
 Base Path:   /usr/share/dotnet/sdk/6.0.109/

global.json file:
  /home/longfin/9c-launcher/NineChronicles.Headless/Lib9c/.Libplanet/global.json

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

.NET SDKs installed:
  3.1.120 [/usr/share/dotnet/sdk]
  6.0.109 [/usr/share/dotnet/sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 3.1.20 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 6.0.9 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 3.1.20 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.9 [/usr/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

[longfin@longfin-desktop-arch .Lib9c.Tools]$ dotnet publish -r osx-arm64 --self-contained
Microsoft (R) Build Engine version 17.0.0+c9eb9dd64 for .NET
Copyright (C) Microsoft Corporation. All rights reserved.

  Determining projects to restore...
  All projects are up-to-date for restore.
  Libplanet.Stun -> /home/longfin/9c-launcher/NineChronicles.Headless/Lib9c/.Libplanet/Libplanet.Stun/bin/Debug/netstandard2.0/Libplanet.Stun.dll
  Libplanet -> /home/longfin/9c-launcher/NineChronicles.Headless/Lib9c/.Libplanet/Libplanet/bin/Debug/netstandard2.0/Libplanet.dll
  Libplanet.RocksDBStore -> /home/longfin/9c-launcher/NineChronicles.Headless/Lib9c/.Libplanet/Libplanet.RocksDBStore/bin/Debug/netstandard2.0/Libplanet.RocksDBStore.dll
  Libplanet.Net -> /home/longfin/9c-launcher/NineChronicles.Headless/Lib9c/.Libplanet/Libplanet.Net/bin/Debug/netstandard2.0/Libplanet.Net.dll
  Libplanet.Analyzers -> /home/longfin/9c-launcher/NineChronicles.Headless/Lib9c/.Libplanet/Libplanet.Analyzers/bin/Debug/netstandard2.0/Libplanet.Analyzers.dll
  Lib9c -> /home/longfin/9c-launcher/NineChronicles.Headless/Lib9c/Lib9c/.bin/netstandard2.0/Lib9c.dll
  Lib9c.DevExtensions -> /home/longfin/9c-launcher/NineChronicles.Headless/Lib9c/Lib9c.DevExtensions/.bin/netstandard2.0/Lib9c.DevExtensions.dll
  Libplanet.Stun -> /home/longfin/9c-launcher/NineChronicles.Headless/Lib9c/.Libplanet/Libplanet.Stun/bin/Debug/netcoreapp3.1/Libplanet.Stun.dll
  Libplanet -> /home/longfin/9c-launcher/NineChronicles.Headless/Lib9c/.Libplanet/Libplanet/bin/Debug/netcoreapp3.1/Libplanet.dll
  Libplanet.Net -> /home/longfin/9c-launcher/NineChronicles.Headless/Lib9c/.Libplanet/Libplanet.Net/bin/Debug/netcoreapp3.1/Libplanet.Net.dll
  Libplanet.Analyzers -> /home/longfin/9c-launcher/NineChronicles.Headless/Lib9c/.Libplanet/Libplanet.Analyzers/bin/Debug/netcoreapp3.1/Libplanet.Analyzers.dll
  Lib9c.Tools -> /home/longfin/9c-launcher/NineChronicles.Headless/Lib9c/.Lib9c.Tools/bin/Debug/net6.0/osx-arm64/9c-tools.dll
  Lib9c.Tools -> /home/longfin/9c-launcher/NineChronicles.Headless/Lib9c/.Lib9c.Tools/bin/Debug/net6.0/osx-arm64/publish/

It seems that main blocker is the pinning netcoreapp3.1 on the csproj. https://github.com/planetarium/libplanet/blob/1a41a33750ab306c4b67346d52415f72b222b444/Libplanet.Tools/Libplanet.Tools.csproj#L23