Description
Description
When loading dependencies of PowerShell on Alpine 3.15, it falls back to load linux-x64 dependencies. The issue does not repro with alpine 3.14. In both cases, the SDK version is 6.0.0.
It was found that the RID for Alpine 3.15 is missing on .NET 6 SDK. See: #62938
Note, dotnet --info does show the correct RID:
~/.dotnet/tools # dotnet --info
.NET SDK (reflecting any global.json):
Version: 6.0.100
Commit: 9e8b04bbff
Runtime Environment:
OS Name: alpine
OS Version: 3.15
OS Platform: Linux
RID: linux-musl-x64
Base Path: /usr/share/dotnet/sdk/6.0.100/
Host (useful for support):
Version: 6.0.0
Commit: 4822e3c3aa
.NET SDKs installed:
6.0.100 [/usr/share/dotnet/sdk]
.NET runtimes installed:
Microsoft.AspNetCore.App 6.0.0 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 6.0.0 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
I have attached load trace logs for the powershell load failure. loadtrace.txt
Excerpt below:
HostRID is alpine.3.15-x64
Falling back to base HostRID: linux-x64
The targeted framework does not support the runtime 'linux-x64'. Some native libraries from [System.Speech/6.0.0] may fail to load on this platform.
The targeted framework does not support the runtime 'linux-x64'. Some native libraries from [System.Speech/6.0.0] may fail to load on this platform.
The targeted framework does not support the runtime 'linux-x64'. Some native libraries from [System.Speech/6.0.0] may fail to load on this platform.
The targeted framework does not support the runtime 'linux-x64'. Some native libraries from [runtime.win-arm64.runtime.native.System.Data.SqlClient.sni/4.4.0] may fail to load on this platform.
The targeted framework does not support the runtime 'linux-x64'. Some native libraries from [runtime.win-arm64.runtime.native.System.Data.SqlClient.sni/4.4.0] may fail to load on this platform.
The targeted framework does not support the runtime 'linux-x64'. Some native libraries from [runtime.win-arm64.runtime.native.System.Data.SqlClient.sni/4.4.0] may fail to load on this platform.
The targeted framework does not support the runtime 'linux-x64'. Some native libraries from [runtime.osx-x64.runtime.native.System.IO.Ports/6.0.0] may fail to load on this platform.
The targeted framework does not support the runtime 'linux-x64'. Some native libraries from [runtime.osx-x64.runtime.native.System.IO.Ports/6.0.0] may fail to load on this platform.
The targeted framework does not support the runtime 'linux-x64'. Some native libraries from [runtime.osx-x64.runtime.native.System.IO.Ports/6.0.0] may fail to load on this platform.
The targeted framework does not support the runtime 'linux-x64'. Some native libraries from [runtime.linux
[loadtrace.txt](https://github.com/dotnet/runtime/files/8043912/loadtrace.txt)
-x64.runtime.native.System.IO.Ports/6.0.0] may fail to load on this platform.
The targeted framework does not support the runtime 'linux-x64'. Some native libraries from [runtime.linux-x64.runtime.native.System.IO.Ports/6.0.0] may fail to load on this platform.
The targeted framework does not support the runtime 'linux-x64'. Some native libraries from [Microsoft.Win32.Registry.AccessControl/6.0.0] may fail to load on this platform.
The targeted framework does not support the runtime 'linux-x64'. Some native libraries from [Microsoft.Win32.Registry.AccessControl/6.0.0] may fail to load on this platform.
The targeted framework does not support the runtime 'linux-x64'. Some native libraries from [Microsoft.Win32.Registry.AccessControl/6.0.0] may fail to load on this platform.
The targeted framework does not support the runtime 'linux-x64'. Some native libraries from [Microsoft.PowerShell.Native/7.2.0] may fail to load on this platform.
The targeted framework does not support the runtime 'linux-x64'. Some native libraries from [Microsoft.PowerShell.Native/7.2.0] may fail to load on this platform.
Chose linux-x64, so removing rid (win-x86) specific assets for package Microsoft.PowerShell.Native/7.2.0 and asset type native
Chose linux-x64, so removing rid (win-arm) specific assets for package Microsoft.PowerShell.Native/7.2.0 and asset type native
Chose linux-x64, so removing rid (win-x64) specific assets for package Microsoft.PowerShell.Native/7.2.0 and asset type native
Chose linux-x64, so removing rid (osx) specific assets for package Microsoft.PowerShell.Native/7.2.0 and asset type native
Reproduction Steps
On Alpine 3.15 container with .NET SDK
dotnet tool install --global PowerShell
~/.dotnet/tools/pwsh
Expected behavior
pwsh should execute correctly
Actual behavior
~/.dotnet/tools # ./pwsh
PowerShell 7.2.1
Copyright (c) Microsoft Corporation.
https://aka.ms/powershell
Type 'help' to get help.
One or more errors occurred. (The type initializer for 'System.Management.Automation.TypeAccelerators' threw an exception.)
One or more errors occurred. (The type initializer for 'System.Management.Automation.TypeAccelerators' threw an exception.)
Cannot load PSReadline module. Console is running without PSReadline.
Process terminated. The type initializer for 'System.Management.Automation.PSObject' threw an exception.
at System.Environment.FailFast(System.String, System.Exception)
at Microsoft.PowerShell.UnmanagedPSEntry.Start(System.String[], Int32)
at Microsoft.PowerShell.ManagedPSEntry.Main(System.String[])
System.TypeInitializationException: The type initializer for 'System.Management.Automation.PSObject' threw an exception.
---> System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.Management.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. The system cannot find the file specified.
Regression?
No response
Known Workarounds
No response
Configuration
.NET SDK 6.0.0
Alpine 3.15
Other information
No response
Activity
danmoseley commentedon Feb 10, 2022
It's a request for backport of #62938
@wfurt we backport these, right?
mthalman commentedon Feb 10, 2022
It's not a matter of defining the Alpine RID. The Alpine RID shouldn't need to be defined for things to work correctly. It should be falling back to the linux-musl RID. The SDK represents correctly but the loader is falling back to
linux, for some reason, notlinux-musl.vitek-karas commentedon Feb 14, 2022
Backporting #62938 would fix this particular case, but I think @mthalman is also correct that the fallback logic in the host should handle MUSL based linuxes as special (it's too common not to).
Basically we need to change this code here:
runtime/src/native/corehost/hostmisc/pal.h
Lines 66 to 87 in 26c9b28
It should have a branch for MUSL linux and return
linux-muslin that case.mthalman commentedon Feb 18, 2022
@vitek-karas - Since this issue shows up in 6.0, can we get it backported to that version?
vitek-karas commentedon Feb 18, 2022
@agocke can you try to flow this through triage?
That said, we shipped like this for a long time (probably ever since .NET 3.1) - so it's likely not that important.
agocke commentedon Feb 18, 2022
Sure, let’s give it a shot
mthalman commentedon Feb 18, 2022
It seems to have revealed itself more so now, for some reason, with PowerShell. This was the original issue that identified this: PowerShell/PowerShell#16532. The issue showed up for .NET 6 but not for .NET 5 even though neither of them had the Alpine RID.
vitek-karas commentedon Feb 18, 2022
Thanks @mthalman - that sounds like a strong enough argument to me to take it. Let's see...