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

Unable to load shared library 'hostfxr' or one of its dependencies on Alpine inside Docker #31848

Closed
bdovaz opened this issue Apr 18, 2023 · 4 comments
Labels
area-Host untriaged Request triage from a team member

Comments

@bdovaz
Copy link

bdovaz commented Apr 18, 2023

Describe the bug

The bug (+ repro case) is in this repository but we think it has more to do with the dotnet SDK: dotnet/roslynator#1060

Following these steps you are supposed to be able to run any tool installed with dotnet tool install:

https://learn.microsoft.com/en-us/dotnet/core/install/linux-alpine#install-net-7

But the reality is that with Roslynator it doesn't work: https://www.nuget.org/packages/Roslynator.DotNet.Cli

One or more errors occurred. (Unable to load shared library 'hostfxr' 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:
Error loading shared library /usr/lib/dotnet/shared/Microsoft.NETCore.App/7.0.4/hostfxr.so: No such file or directory
Error loading shared library /root/.dotnet/tools/.store/roslynator.dotnet.cli/0.5.0/roslynator.dotnet.cli/0.5.0/tools/net7.0/any/hostfxr.so: No such file or directory
Error loading shared library hostfxr.so: No such file or directory
Error loading shared library /usr/lib/dotnet/shared/Microsoft.NETCore.App/7.0.4/libhostfxr.so: No such file or directory
Error loading shared library /root/.dotnet/tools/.store/roslynator.dotnet.cli/0.5.0/roslynator.dotnet.cli/0.5.0/tools/net7.0/any/libhostfxr.so: No such file or directory
Error loading shared library libhostfxr.so: No such file or directory
Error loading shared library /usr/lib/dotnet/shared/Microsoft.NETCore.App/7.0.4/hostfxr: No such file or directory
Error loading shared library /root/.dotnet/tools/.store/roslynator.dotnet.cli/0.5.0/roslynator.dotnet.cli/0.5.0/tools/net7.0/any/hostfxr: No such file or directory
Error loading shared library hostfxr: No such file or directory
Error loading shared library /usr/lib/dotnet/shared/Microsoft.NETCore.App/7.0.4/libhostfxr: No such file or directory
Error loading shared library /root/.dotnet/tools/.store/roslynator.dotnet.cli/0.5.0/roslynator.dotnet.cli/0.5.0/tools/net7.0/any/libhostfxr: No such file or directory
Error loading shared library libhostfxr: No such file or directory
)
  Inner exception: Unable to load shared library 'hostfxr' 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:

Error loading shared library /usr/lib/dotnet/shared/Microsoft.NETCore.App/7.0.4/hostfxr.so: No such file or directory
Error loading shared library /root/.dotnet/tools/.store/roslynator.dotnet.cli/0.5.0/roslynator.dotnet.cli/0.5.0/tools/net7.0/any/hostfxr.so: No such file or directory
Error loading shared library hostfxr.so: No such file or directory
Error loading shared library /usr/lib/dotnet/shared/Microsoft.NETCore.App/7.0.4/libhostfxr.so: No such file or directory
Error loading shared library /root/.dotnet/tools/.store/roslynator.dotnet.cli/0.5.0/roslynator.dotnet.cli/0.5.0/tools/net7.0/any/libhostfxr.so: No such file or directory
Error loading shared library libhostfxr.so: No such file or directory
Error loading shared library /usr/lib/dotnet/shared/Microsoft.NETCore.App/7.0.4/hostfxr: No such file or directory
Error loading shared library /root/.dotnet/tools/.store/roslynator.dotnet.cli/0.5.0/roslynator.dotnet.cli/0.5.0/tools/net7.0/any/hostfxr: No such file or directory
Error loading shared library hostfxr: No such file or directory
Error loading shared library /usr/lib/dotnet/shared/Microsoft.NETCore.App/7.0.4/libhostfxr: No such file or directory
Error loading shared library /root/.dotnet/tools/.store/roslynator.dotnet.cli/0.5.0/roslynator.dotnet.cli/0.5.0/tools/net7.0/any/libhostfxr: No such file or directory
Error loading shared library libhostfxr: No such file or directory
@dotnet-issue-labeler
Copy link

I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.

@dotnet-issue-labeler dotnet-issue-labeler bot added the untriaged Request triage from a team member label Apr 18, 2023
@marcpopMSFT
Copy link
Member

CC @vitek-karas @elinor-fung

@vitek-karas
Copy link
Member

I'm pretty sure the root cause is described here: microsoft/MSBuildLocator#210
In the SDK this was resolved (As described in the issue above) by passing a variable from the host to the SDK, which then uses it to load the same hostfxr as the host used to start the SDK. Microsoft.Build.Locator should use the same logic.

@YuliiaKovalova
Copy link
Member

YuliiaKovalova commented Aug 30, 2023

The issue was addressed in the scope of dotnet/msbuild#9038

You can use the package with the fix https://www.nuget.org/packages/Microsoft.Build.Locator/1.6.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-Host untriaged Request triage from a team member
Projects
None yet
Development

No branches or pull requests

4 participants