Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Self-contained applications in Linux does not work #6325

Closed
AlbertoMonteiro opened this issue Jun 6, 2016 · 27 comments
Closed

Self-contained applications in Linux does not work #6325

AlbertoMonteiro opened this issue Jun 6, 2016 · 27 comments

Comments

@AlbertoMonteiro
Copy link

Steps to reproduce

  • mkdir hwapp
  • cd hwapp
  • dotnet new
  • Modify project.json to match self-contained app
{
  "version": "1.0.0-*",
  "buildOptions": {
    "emitEntryPoint": true
  },
  "dependencies": {
    "Microsoft.NETCore.App": "1.0.0-rc2-3002702"
  },
  "frameworks": {
    "netcoreapp1.0": {}
  },
  "runtimes": {
    "ubuntu.14.04-x64: {}
  }
}
  • dotnet restore
  • dotnet publish -o out
  • cd out
  • hwapp

Expected behavior

Print Hello World!

Actual behavior

hwapp: command not found

Environment data

.NET Command Line Tools (1.0.0-preview1-002702)

Product Information:
 Version:     1.0.0-preview1-002702
 Commit Sha:  6cde21225e

Runtime Environment:
 OS Name:     ubuntu
 OS Version:  14.04
 OS Platform: Linux
 RID:         ubuntu.14.04-x64
@TheRealPiotrP
Copy link
Contributor

@AlbertoMonteiro can you share the contents of the out directory?

You should also try running ./hwapp. @brthor suspects this is the issue here.

@brthor
Copy link
Contributor

brthor commented Jun 6, 2016

@AlbertoMonteiro I am not able to repro this when using ./hwapp

This is a linux shell requirement, and not something we control in the cli.

Please reopen if you still have issues.

@brthor brthor closed this as completed Jun 6, 2016
@henrylle
Copy link

henrylle commented Jun 7, 2016

I have the same problem, but after exec ./hwapp I get this below error:
"Failed to load /home/ubuntu/teste-dotnet-rc2/libcoreclr.so, error: libunwind.so.8: cannot open shared object file: No such file or directory"

@AlbertoMonteiro
Copy link
Author

@brthor It worked on the machined(ubuntu.14.04-x64) that I ran the publish command. I copied the output to another Linux distro(AWS Linux), and I got the same error pointed by @henrylle

Failed to load /home/ubuntu/teste-dotnet-rc2/libcoreclr.so, error: libunwind.so.8: cannot open shared object file: No such file or directory

@brthor
Copy link
Contributor

brthor commented Jun 7, 2016

@henrylle @AlbertoMonteiro Have you installed the dependencies of .NET Core?

You can use the debian package to bring them in with the installation of the cli or you need to install them manually.

You can see the list of packages in this dockerfile:
https://github.com/dotnet/cli/blob/rel/1.0.0/scripts/docker/ubuntu.14.04/Dockerfile#L20

@oshz
Copy link

oshz commented Sep 8, 2016

@dejfcz
Copy link

dejfcz commented Feb 25, 2017

For anyone still running into this, try

apt-get install libunwind8

@Sword-Smith
Copy link

@dejfcz 's answer solved this problem for me.

@josemotta
Copy link

@dejfcz 's answer solved this problem for me too!

@code4clouds
Copy link

It solves the problem, but not the real issue. The application is not self-contained if it depends on a workaround. A self-contain application should run using just the kernel (i.e. Go with Docker scratch image).

@poma
Copy link

poma commented Sep 30, 2017

Or at least it should display a message that dependency is not installed

@wklm
Copy link

wklm commented Nov 4, 2017

any updates on that? Is it possible to make a build truly self contained and include this dependency somehow?

@xczdbb
Copy link

xczdbb commented Nov 8, 2017

On CoreOS, it's impossible to install libunwind because CoreOS doesn't have a package manager. A workaround is creating a container (Fedora/Ubuntu/etc) and run my .net core app inside it, but it's quite indirect. What's the correct way to deploy self-contained app on CoreOS?

@livarcocc
Copy link
Contributor

This is not really a CLI issue at this point. When you are running a self-contained app or a portable app, you only use the runtime for that. I would suggest filling a separate issue about native dependencies on CoreOS over at dotnet/core-setup.

@wklm
Copy link

wklm commented Nov 8, 2017

could we simply make the libunwind a part of the build in case it's not present on the os?

@olandese
Copy link

olandese commented Nov 8, 2017

I was having the same problem on ubuntu 17.04, after installing libunwind8 with apt the .NET Core application was running successfully.
With a self contained application this should work without the need to install anything

@ghost
Copy link

ghost commented Nov 9, 2017

Today we published and tried to run simple console app on fresh ubuntu WSL (16.04 LTS) & ubuntu azure (16.04 LTS). dotnetcore2
Tried linux-x64 & ubuntu.16.04-x64 runtime setups.

The same problem appeared. Installing libunwind8 did the job.

Is it going to be fixed at all? This way linux publish is not self contained. PERIOD.
We could install full dotnet runtime this way...

@dasMulli
Copy link
Contributor

dasMulli commented Nov 9, 2017

There is a document describing how to include 3rd party libraries for self-contained apps: https://github.com/dotnet/core/blob/master/Documentation/self-contained-linux-apps.md

Related: https://github.com/dotnet/coreclr/issues/5853
Which was closed with https://github.com/dotnet/coreclr/issues/5853#issuecomment-297864286

After the investigations and various experiments, it turned out that static linking is not feasible from various points of view and that a better approach to achieve portability over Linux distros is to change linking of some dependencies from build time to run time and to enable bundling of local copies of shared libraries. This has proven to work well, so I am closing this issue.

@WhatFreshHellIsThis
Copy link

Having the same issue "error: libunwind.so.8: cannot open shared object file: No such file or directory" This needs to be fixed.

@brthor
Copy link
Contributor

brthor commented Mar 7, 2018

When all else fails, pull the missing libraries from the microsoft docker image.
You can put them in the publish directory and distribute them with your app.

Quick example from my macbook:

Creating the project:

$ mkdir test && cd test
$ dotnet new console && dotnet publish -r linux-x64 --self-contained -o bin

If you run it on linux, expected result:

$ docker run -it -v $(pwd)/bin:/export ubuntu:latest /export/export
Failed to load ��', error: libunwind.so.8: cannot open shared object file: No such file or directory
Failed to bind to CoreCLR at '/export/libcoreclr.so'

Pull the libraries via docker (libunwind and libicu) and to your publish directory:

$ docker run -v $(pwd)/bin:/export microsoft/dotnet:2.0.0-sdk bash -c "cp /usr/lib/x86_64-linux-gnu/libicu* /export/"

$ docker run -v $(pwd)/bin:/export microsoft/dotnet:2.0.0-sdk bash -c "cp /usr/lib/x86_64-linux-gnu/libunwind* /export/"

Re-test:

$ docker run -it -v $(pwd)/bin:/export ubuntu:latest bash -c "LD_LIBRARY_PATH=/export /export/export"
Hello World

Success!

@WhatFreshHellIsThis @dasMulli @FDUdannychen

@lindexi
Copy link
Member

lindexi commented Apr 7, 2018

@brthor I still cant run in my arm-32 for I cant install any lib.

@brthor
Copy link
Contributor

brthor commented Apr 7, 2018

@lindexi You're going to have to pull the libraries from one of the ARM 32 docker images. I suspect the path to the libraries will be different as well (not /usr/lib/x86_64-linux-gnu)

(See Here)[https://hub.docker.com/r/microsoft/dotnet/]

@brthor
Copy link
Contributor

brthor commented Apr 7, 2018

@livarcocc The experience surrounding this issue is awful, consider reopening it and fixing at least the experience if not the issue itself.

The average .NET Core user has no clue what libunwind is, and probably jumps back to building their service in Node.js or Ruby after they see an error like this.

This isn't an isolated incident either, this is a problem for EVERY self-contained linux app deployed to a machine without a portable framework installed. Self-contained apps are exactly the same as portable apps from a (single) deployment and usability perspective, for this reason.

There are several ways to solve this problem (without distributing the libraries yourself), I think the easiest of which is to print a command or set of commands that the user can copy/paste to run on their target machine (i.e. apt-get install libunwind8) whenever they do a self-contained deployment to a linux-x64 or child RID.

@lindexi
Copy link
Member

lindexi commented Apr 8, 2018

@brthor Thx , but I cant install anything on my linux for it's a microcomputer that can only install when reinstalling the system. That I cant use docker or install libunwin.so.8 .

@adeel41
Copy link

adeel41 commented Sep 23, 2018

For anyone still running into this, try

apt-get install libunwind8

Or if you running on CentOs then run
sudo yum install libunwind

@alexellis
Copy link

I just had this issue with .NET Core 2.2 on ARMHF and Docker. The fix was to add the libunwind apt package to the .NET core runtime container, I can't think why it wasn't already bundled into the runtime container image?

@msftgits msftgits transferred this issue from dotnet/cli Jan 31, 2020
@zaneclaes
Copy link

zaneclaes commented Jun 4, 2021

5 years later, this is still happening with arm32v7 when creating a Docker image from the official dotnet5 Dockerfile. I am able to build that official Dockerfile on a RPi, but the resulting image will not run. However, I note that the official Dockerfile includes --self-contained false, making me wonder if dependencies were accidentally omitted. I added the libunwind8 dependency, but then ran into this issue instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests