You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
System.PlatformNotSupportedException: System.IO.Ports is currently only supported on Windows. on Archlinux #79196
When using IO Ports on ArchLinux System and dotnet 7.0 or 6.0 I get an exception System.PlatformNotSupportedException: System.IO.Ports is currently only supported on Windows.
SerialPort.GetPortNames() works but not SerialPort()
╰─ lsb_release -a
LSB Version: n/a
Distributor ID: EndeavourOS
Description: EndeavourOS Linux
Release: rolling
Codename: rolling
╰─ uname -a
Linux keelah-dellG15 6.0.9-arch1-1 #1 SMP PREEMPT_DYNAMIC Wed, 16 Nov 2022 17:01:17 +0000 x86_64 GNU/Linux
CPU Architecture :
╰─ uname -m
x86_64
From what I've seen on the forums, it works on certain linux distros but not on others such as Manjaro and EndeavourOS (both running archlinux) and might be the same on other more obscure linux distros
Other information
A few lines of code I used on my console program :
//DEFAULT port sur /dev/ttyUSB0stringSERIALPORT="/dev/ttyUSB0";//Line below worksList<string>ports=SerialPort.GetPortNames().ToList();SERIALPORT=ports.Last();//Crash on line belowSerialPort_serialPort=newSerialPort(SERIALPORT,BAUDRATE,Parity.None,8,StopBits.One);_serialPort.ReadTimeout=-1;// |Pas de timeout_serialPort.WriteTimeout=-1;// |_serialPort.Handshake=Handshake.None;_serialPort.DataReceived+=_serialPort_DataReceived;
I had TargetFramework on <TargetFramework>net6.0</TargetFramework> and tried net7.0 too.
Also had <PackageReference Include="System.IO.Ports" Version="7.0.0" />
@Foxlider if you have some time to experiment...
I'm curious if you published for linux-x64 (dotnet publish -r linux-x64 and then run binary produced under bin/.../publish) - there is a chance it will just work. Or alternatively you could copy & paste System.IO.Ports binaries from linux-x64 (there should be .dll and .so file) to your other build (replace existing ones)
We seem to not produce bits for arch-64 currently but I'm curious if we could just make arch use linux bits.
So it seems publishing with linux-x64 works and so is dotnet run -r linux-x64
I am not sure why arch-x64 is considered as a different system as linux since it still uses the linux kernel as any other linux system. Or if there is a difference, I am unsure what it is
@Foxlider I'm guessing some of the native components in different areas need some arch specific binaries. Having said that I think arch should extend linux RID and IMO we should be picking up linux-x64 package if arch-x64 is not present. I'll see if I can find someone who knows what needs to be changed to fix this.
I followed @am11 sample from above and didn't get a PlatformNotSupportedException when performing a dotnet run but the intended output: "Done" on my Arch distro.
@Foxlider can you please share a minimal but complete repro?
/etc/os-release contract is bad and should be avoided because it can be avoided:
This reliance on/etc/os-release is a weakness in our design and I'm very happy that NativeAOT hosting layer does not use all that (hope it stays this way). The design should be so that we shouldn't be parsing /etc/os-release file in the first place for anything (more serious than dotnet --info); let alone failing hard if /etc/os-release does not have some expected values on the user system. This file is not part of or owned by dotnet, so we should not monitor and object to random stuff on user system and fail to run because of that.
This is missing for the non-portable build, and that is a source-build issue.
The information comes from Microsoft.NETCore.App.deps.jsonruntimes section.
For the non-portable build, grep -F '"linux-x64": [' Microsoft.NETCore.App.deps.json comes up empty.
We need to verify this section is present.
#78563 is a similar issue, also due to a broken runtimes section. It is fixed on main, 7.0 and maybe 6.0.
Without it, the non-portable build doesn't know the parents of linux-x64. It needs to know unix is a parent, because that is what System.IO.Ports provides.
Wow, extremely impressive. So now we already have a patched 7.0.2 SDK available on ArchLinux which doesn't reproduce the issue. Fantastic! @am11 to not get out of sync with our own release/7.0 branch, should we backport the host fix? Otherwise if someone would build .NET 7 for ArchLinux from source again without your patch, the issue would re-appear.
@ViktorHofer, I think it does not warrant a backport in our release/7.0 branch simply because this is not a regression. :)
The non-portable flavor is there since .NET Core 1.0, it was portable that came later around .NET Core 2 when we realized having separate builds for each distro is not scalable model. Plus, this is the first report of the exception which is limited to nuget-with-native-binary on Arch Linux; a-rolling-release distro with VERSION_ID line in /etc/os-release which our sensitive parsing wasn't expecting.
Reacted by Viktor Hofer
ghost locked as resolved and limited conversation to collaborators on Mar 7, 2023
Activity
Foxlider commentedon Dec 6, 2022
I had
TargetFrameworkon<TargetFramework>net6.0</TargetFramework>and tried net7.0 too.Also had
<PackageReference Include="System.IO.Ports" Version="7.0.0" />I'll check your code on my Arch..
krwq commentedon Jan 13, 2023
What RID does your
dotnet --infoshow (second section of the output under Runtime Environment)?Foxlider commentedon Jan 15, 2023
RID is
arch-x64Still have the same error on the
GetPortsNamethoughkrwq commentedon Jan 17, 2023
@Foxlider if you have some time to experiment...
I'm curious if you published for
linux-x64(dotnet publish -r linux-x64and then run binary produced under bin/.../publish) - there is a chance it will just work. Or alternatively you could copy & paste System.IO.Ports binaries from linux-x64 (there should be .dll and .so file) to your other build (replace existing ones)We seem to not produce bits for arch-64 currently but I'm curious if we could just make arch use linux bits.
Foxlider commentedon Jan 17, 2023
So it seems publishing with
linux-x64works and so isdotnet run -r linux-x64I am not sure why arch-x64 is considered as a different system as linux since it still uses the linux kernel as any other linux system. Or if there is a difference, I am unsure what it is
krwq commentedon Jan 19, 2023
@Foxlider I'm guessing some of the native components in different areas need some arch specific binaries. Having said that I think arch should extend linux RID and IMO we should be picking up linux-x64 package if arch-x64 is not present. I'll see if I can find someone who knows what needs to be changed to fix this.
krwq commentedon Jan 19, 2023
cc: @ViktorHofer
ViktorHofer commentedon Jan 19, 2023
I followed @am11 sample from above and didn't get a PlatformNotSupportedException when performing a
dotnet runbut the intended output: "Done" on my Arch distro.@Foxlider can you please share a minimal but complete repro?
Foxlider commentedon Jan 19, 2023
Let me know if you need anything.
I tried a minimal code with a
dotnet new consoleand simply adding theSerialPort.GetPortNames()and still had the issue13 remaining items
am11 commentedon Feb 2, 2023
@tmds, the fallback RID is in the graph of portable build and missing in non-portable build.
non-portable http://sprunge.us/TypCOf
portable http://sprunge.us/QlIRXQ
(search for
The rid fallback graph is)/etc/os-releasecontract is bad and should be avoided because it can be avoided:This reliance on
/etc/os-releaseis a weakness in our design and I'm very happy that NativeAOT hosting layer does not use all that (hope it stays this way). The design should be so that we shouldn't be parsing/etc/os-releasefile in the first place for anything (more serious thandotnet --info); let alone failing hard if/etc/os-releasedoes not have some expected values on the user system. This file is not part of or owned by dotnet, so we should not monitor and object to random stuff on user system and fail to run because of that.tmds commentedon Feb 2, 2023
I was just also looking into this.
In both cases you see:
The difference is in the fallback graph:
This is missing for the non-portable build, and that is a source-build issue.
The information comes from
Microsoft.NETCore.App.deps.jsonruntimessection.For the non-portable build,
grep -F '"linux-x64": [' Microsoft.NETCore.App.deps.jsoncomes up empty.We need to verify this section is present.
#78563 is a similar issue, also due to a broken
runtimessection. It is fixed onmain,7.0and maybe6.0.tmds commentedon Feb 2, 2023
Without it, the non-portable build doesn't know the parents of
linux-x64. It needs to knowunixis a parent, because that is whatSystem.IO.Portsprovides.am11 commentedon Feb 4, 2023
Found a (semi-) good state of VMR from their
release/8.0.1xx-preview1branch: https://github.com/dotnet/dotnet/tree/a2aca774110aadd68f5e2ad7b99293ab28d5632b (which requires dotnet/source-build-assets#513). I can confirm that non-portable build is fixed.Last two lines of output:
am11 commentedon Feb 4, 2023
Hi @alucryd, if you could apply https://github.com/dotnet/runtime/commit/31e4f404c218eae7ba999c4df5346d30f971451c.patch to https://github.com/archlinux/svntogit-community/blob/ca544978888af3d305f8ef5051622ff1d04b102c/dotnet-core/trunk/PKGBUILD for .NET 7 and publish a new release, it will unblock @Foxlider. In the upcoming .NET 8, that patch won't be necessary. Thanks!
Foxlider commentedon Feb 5, 2023
Do you need me to test anything? Or should I wait for next release ?
If I do, what commands do I need to run ?
am11 commentedon Feb 5, 2023
#79196 (comment) is testing with .NET 8 preview 1 local build using docker. You can try it if you like.
For .NET 7 release, if @alucryd can apply that patch directly to Arch Linux package source (since that's the affected distro atm), that will make backporting quicker. Otherwise, we can try to request its backport for https://github.com/dotnet/runtime/tree/release/7.0 branch, which once accepted, might take a month or two before it would make its way to the next .NET 7 servicing release.
alucryd commentedon Feb 5, 2023
@am11 Done, patched package is up :)
dotnet-core 7.0.2.sdk102-2: dotnet/runtime#79196
dotnet-core 7.0.2.sdk102-2: dotnet/runtime#79196
am11 commentedon Feb 5, 2023
Thanks @alucryd! 🎉
I ran a quick test and the exception does not reproduce with the latest package
dotnet-sdk-7.0.2.sdk102-2-x86_64.result:
ViktorHofer commentedon Feb 5, 2023
Wow, extremely impressive. So now we already have a patched 7.0.2 SDK available on ArchLinux which doesn't reproduce the issue. Fantastic! @am11 to not get out of sync with our own release/7.0 branch, should we backport the host fix? Otherwise if someone would build .NET 7 for ArchLinux from source again without your patch, the issue would re-appear.
am11 commentedon Feb 5, 2023
@ViktorHofer, I think it does not warrant a backport in our release/7.0 branch simply because this is not a regression. :)
The non-portable flavor is there since .NET Core 1.0, it was portable that came later around .NET Core 2 when we realized having separate builds for each distro is not scalable model. Plus, this is the first report of the exception which is limited to nuget-with-native-binary on Arch Linux; a-rolling-release distro with
VERSION_IDline in/etc/os-releasewhich our sensitive parsing wasn't expecting.