Skip to content

System.IO.Ports.SerialPort not working on linux-musl-arm #104710

@cskowronnek

Description

@cskowronnek

Description

After waiting for the fix in #63187 I gave it a try but it unfortunately fails.
With:
Unable to load shared library 'libSystem.IO.Ports.Native' or one of its dependencies. In order to help diagnose loading problems, consider using a tool like strace. If you're using glibc, consider setting the LD_DEBUG environment variable: \nError loading shared library ld-linux-armhf.so.3: No such file or directory (needed by /app/libSystem.IO.Ports.Native.so)\nError loading shared library /usr/share/dotnet/shared/Microsoft.NETCore.App/9.0.0-preview.6.24327.7/libSystem.IO.Ports.Native.so: No such file or directory\nError loading shared library libSystem.IO.Ports.Native.so: No such file or directory\nError loading shared library /app/liblibSystem.IO.Ports.Native.so: No such file or directory\nError loading shared library /usr/share/dotnet/shared/Microsoft.NETCore.App/9.0.0-preview.6.24327.7/liblibSystem.IO.Ports.Native.so: No such file or directory\nError loading shared library liblibSystem.IO.Ports.Native.so: No such file or directory\nError loading shared library /app/libSystem.IO.Ports.Native: No such file or directory

Dockerfile:

FROM mcr.microsoft.com/dotnet/sdk:9.0.100-preview.6-alpine3.20 AS build-env

ARG DOTNET_PLATFORM

WORKDIR /app

COPY *.csproj ./

RUN dotnet restore -r linux-musl-arm

COPY . ./
RUN dotnet publish -c Release -o out -r linux-musl-arm


FROM mcr.microsoft.com/dotnet/runtime:9.0.0-preview.6-alpine3.20-arm32v7
WORKDIR /app


COPY --from=build-env /app/out ./

ENTRYPOINT ["dotnet", "controller_module.dll"]

csproj

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net9.0</TargetFramework>
    <RootNamespace>Draeger.RSS.RentalRobot.LockerController</RootNamespace>
    <Nullable>enable</Nullable>
    <LangVersion>8.0</LangVersion>
    <WarningsAsErrors>nullable</WarningsAsErrors>
  </PropertyGroup>
  
  <ItemGroup>
    <ProjectCapability Include="AzureIoTEdgeModule" />
  </ItemGroup>

  <ItemGroup>
    <PackageReference Include="System.IO.Ports" Version="9.0.0-preview.6.24327.7" />

Logs

{"@t":"2024-07-10T09:05:46.9072401Z","@m":"Writing to serial port, attempt 1 of 3.","@i":"ff057a1a","@l":"Debug","SourceContext":"Controller.LockerDriver","iotHubDeviceId":"SOCP2001","iotHubName":"iothub","moduleName":"controller_module","DeployableName":"ControllerIotModule","DeployableType":"IotModule"}
{"@t":"2024-07-10T09:05:46.9180450Z","@m":"Opening serial port...","@i":"6dd64a39","@l":"Debug","SourceContext":"Controller.LockerDriver","iotHubDeviceId":"SOCP2001-21011111","iotHubName":"iothub","moduleName":"controller_module","DeployableName":"ControllerIotModule","DeployableType":"IotModule"}
{"@t":"2024-07-10T09:05:46.9424206Z","@m":"Unexpected error during open locker request, Unable to load shared library 'libSystem.IO.Ports.Native' or one of its dependencies. In order to help diagnose loading problems, consider using a tool like strace. If you're using glibc, consider setting the LD_DEBUG environment variable: \nError loading shared library ld-linux-armhf.so.3: No such file or directory (needed by /app/libSystem.IO.Ports.Native.so)\nError loading shared library /usr/share/dotnet/shared/Microsoft.NETCore.App/9.0.0-preview.6.24327.7/libSystem.IO.Ports.Native.so: No such file or directory\nError loading shared library libSystem.IO.Ports.Native.so: No such file or directory\nError loading shared library /app/liblibSystem.IO.Ports.Native.so: No such file or directory\nError loading shared library /usr/share/dotnet/shared/Microsoft.NETCore.App/9.0.0-preview.6.24327.7/liblibSystem.IO.Ports.Native.so: No such file or directory\nError loading shared library liblibSystem.IO.Ports.Native.so: No such file or directory\nError loading shared library /app/libSystem.IO.Ports.Native: No such file or directory\nError loading shared library /usr/share/dotnet/shared/Microsoft.NETCore.App/9.0.0-preview.6.24327.7/libSystem.IO.Ports.Native: No such file or directory\nError loading shared library libSystem.IO.Ports.Native: No such file or directory\nError loading shared library /app/liblibSystem.IO.Ports.Native: No such file or directory\nError loading shared library /usr/share/dotnet/shared/Microsoft.NETCore.App/9.0.0-preview.6.24327.7/liblibSystem.IO.Ports.Native: No such file or directory\nError loading shared library liblibSystem.IO.Ports.Native: No such file or directory\n","@i":"aedd1ac1","@l":"Error","SourceContext":"Controller.Domain.OpenLockerUseCase","iotHubDeviceId":"SOCP2001","iotHubName":"iothub","moduleName":"controller_module","DeployableName":"ControllerIotModule","DeployableType":"IotModule"}

Reproduction Steps

Build with newest System.IO lib for linux-musl-arm

Expected behavior

Lib working as expected

Actual behavior

Lib not found

Regression?

No response

Known Workarounds

No response

Configuration

No response

Other information

No response

Metadata

Metadata

Assignees

Labels

area-System.IO.Portsin-prThere is an active PR which will close this issue when it is merged

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions