question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error Loading Native Library in Docker .NET 6

See original GitHub issue

I am not sure whether this is a supported use case, but it has been working just fine in .NET 5 for us, I ended up updating everything to .NET 6 and gui.cs is breaking on loading native library, strangely it doesn’t seem to mention which library at all. Docker image is just based off mcr.microsoft.com/dotnet/runtime:6.0, nothing added to it.

I have attached the stack trace below, let me know if more information is necessary

Stack Trace:

Curses failed to initialize, the exception is: System.IO.IOException: Error loading native library ""
   at Unix.Terminal.UnmanagedLibrary..ctor(String[] libraryPathAlternatives, Boolean isFullPath)
   at Unix.Terminal.Curses.LoadMethods()
   at Unix.Terminal.Curses.FindNCurses()
   at Unix.Terminal.Curses.initscr()
   at Terminal.Gui.CursesDriver.Init(Action terminalResized)
Unhandled exception. System.NullReferenceException: Object reference not set to an instance of an object.
   at Unix.Terminal.Curses.doupdate()
   at Terminal.Gui.CursesDriver.Init(Action terminalResized)
   at Terminal.Gui.Application.Init(Func`1 topLevelFactory, ConsoleDriver driver, IMainLoopDriver mainLoopDriver)
   at Terminal.Gui.Application.Init(ConsoleDriver driver, IMainLoopDriver mainLoopDriver)
   ....

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:37

github_iconTop GitHub Comments

4reactions
Nutzzzcommented, Jun 15, 2023

Leave off the .so. For Ubuntu the packages are named libncursesw5 and/or libncursesw6.

Like I said, I’ve hardly used this library in Linux, and never with a container.

EDIT: I don’t know if this helps, but it seems to be discussing exactly your problem.

1reaction
BDispcommented, Jun 17, 2023

With the original Dockerfile it’s possible get it to work with this modification:

#See https://aka.ms/customizecontainer to learn how to customize your debug container and how Visual Studio uses this Dockerfile to build your images for faster debugging.

FROM mcr.microsoft.com/dotnet/runtime:6.0 AS base
RUN apt-get update && apt-get upgrade -y && apt-get install -y ncurses-dev locales && \
	sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen && \
    dpkg-reconfigure --frontend=noninteractive locales && \
    update-locale LANG=en_US.UTF-8
ENV LANG=en_US.UTF-8 \
	TERM=xterm-256color
WORKDIR /app

FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
WORKDIR /src
COPY ["RainLispConsole/RainLispConsole.csproj", "RainLispConsole/"]
RUN dotnet restore "RainLispConsole/RainLispConsole.csproj"
COPY . .
WORKDIR "/src/RainLispConsole"
RUN dotnet build "RainLispConsole.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "RainLispConsole.csproj" -c Release -o /app/publish /p:UseAppHost=false

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "RainLispConsole.dll"]

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error Loading Native Library in Docker .NET 6 · Issue #1513
cs is breaking on loading native library, strangely it doesn't seem to mention which library at all. Docker image is just based off...
Read more >
Error loading native library "/app/runtimes/linux ...
I'm build a web API app using .NET core and gRPC for Csharp. In Local, It work verry well, but when I build...
Read more >
[Solved]-Error loading native library "/app/runtimes/linux/native ...
Coding example for the question Error loading native library "/app/runtimes/linux/native/libgrpc_csharp_ext.x64.so - Grpc Core on Docker container-docker.
Read more >
Debugging native library dependencies on Linux
I'm trying to run my C# app (Net 5) in a docker Linux container on my Windows 10 Pro system. I get this...
Read more >
How to Handle the UnsatisfiedLinkError Runtime Error in ...
The Java java.lang.UnsatisfiedLinkError is thrown when a program uses a native libaray but is unable to find it at runtime for some reason....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found