Skip to content

The "--use-current-runtime" option doesn't work correctly in Arm-based musl system (Alpine) #28809

Closed
@mthalman

Description

@mthalman

The --use-current-runtime option should make use of the current system's RID. This is not working currently when that system is on the Arm architecture and musl-based. I specifically used Alpine. Not sure if it's all musl systems or just specific to Alpine since Alpine has its own RID. It's essentially treating it as a non-musl-based system. In other words, it's deriving the RID as linux-arm64 instead of linux-musl-arm64. What's interesting is that this only occurs for Arm64/Arm32 but not x64.

This can be shown in two ways using the dotnet restore and dotnet publish commands.

Repro steps

  1. Install .NET 7 RC2 SDK
  2. Verify RID by running dotnet --info:
.NET SDK:
 Version:   7.0.100-rc.2.22477.23
 Commit:    0a5360315a

Runtime Environment:
 OS Name:     alpine
 OS Version:  3.16
 OS Platform: Linux
 RID:         alpine.3.16-arm64
 Base Path:   /usr/share/dotnet/sdk/7.0.100-rc.2.22477.23/

Host:
  Version:      7.0.0-rc.2.22472.3
  Architecture: arm64
  Commit:       550605cc93

.NET SDKs installed:
  7.0.100-rc.2.22477.23 [/usr/share/dotnet/sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 7.0.0-rc.2.22476.2 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 7.0.0-rc.2.22472.3 [/usr/share/dotnet/shared/Microsoft.NETCore.App]

Other architectures found:
  None

Environment variables:
  Not set

global.json file:
  Not found

Learn more:
  https://aka.ms/dotnet/info

Download .NET:
  https://aka.ms/dotnet/download
  1. Create a simple console app: dotnet new console
  2. Restore the project: dotnet restore --use-current-runtime -v normal

Notice in the output that package names are not specific to musl when they should be. For example, linux-arm64 should be linux-musl-arm64 in this output:

GET https://api.nuget.org/v3-flatcontainer/microsoft.netcore.app.runtime.linux-arm64/7.0.0-rc.2.22472.3/microsoft.netcore.app.runtime.linux-arm64.7.0.0-rc.2.22472.3.nupkg
  1. Restore again, this time explicitly specifying the RID: dotnet restore -r linux-musl-arm64
  2. Now attempt to publish using the --use-current-runtime option: dotnet publish -c Release -o /app --use-current-runtime --no-restore

And you get this error because it's trying to use linux-arm64 instead of linux-musl-arm64:

/usr/share/dotnet/sdk/7.0.100-rc.2.22477.23/Sdks/Microsoft.NET.Sdk/targets/Microsoft.PackageDependencyResolution.targets(267,5): error NETSDK1047: Assets file '/source/obj/project.assets.json' doesn't have a target for 'net7.0/linux-arm64'. Ensure that restore has run and that you have included 'net7.0' in the TargetFrameworks for your project. You may also need to include 'linux-arm64' in your project's RuntimeIdentifiers. [/source/aspnetapp.csproj]

If you just use --use-current-runtime for all these steps and ignore the fact it's not doing the right stuff, the app won't run because it's not using the correct bits for the system it's running on. You end up getting this fun error when attempting to run the app:

standard_init_linux.go:228: exec user process caused: no such file or directory

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions