Hasty Briefsbeta

Fixing an old .NET Core native library loading issue on Alpine

14 days ago
  • #Alpine Linux
  • #.NET
  • #SQLite
  • Issue encountered when testing an app using Microsoft.Data.SQLite on Alpine Linux, resulting in 'Unable to load shared library 'e_sqlite3'' error.
  • .NET 10 requires Alpine 3.17+, causing compatibility issues with older Alpine versions like 3.14.
  • Problem isolated to .NET Core 3.1 and .NET 5 on Alpine 3.17, where the SQLite library couldn't be loaded.
  • Debugging steps included checking dependencies with 'ldd' and using 'LD_DEBUG' and 'LD_LIBRARY_PATH' to trace library loading issues.
  • Root cause identified as .NET runtime ID resolution failure for Alpine 3.17+ in older .NET versions, leading to incorrect runtime ID selection.
  • Solution involved setting 'DOTNET_RUNTIME_ID=linux-musl-x64' to force the correct runtime ID, resolving the library loading issue.