Skip to content

Improve error message when failing to load runtime #75

Open
@egaudrain

Description

@egaudrain

When using:

import clr_loader
clr_loader.get_coreclr()

If the loading fails, we merely get this error:

RuntimeError: Could not find a suitable hostfxr library in /usr/local/share/dotnet

This is not very easy to debug because we don't know why the hostfxr might not be suitable.

The culprit is this piece of code, which just silences the error:

try:
return ffi.dlopen(str(hostfxr_path))
except Exception:
pass

I get that, in the logic of the code, if a runtime is found, we don't want to display a whole bunch of clutter... But in the case where no runtime was found, it seems helpful to have some more details?

For instance, after digging, I found that the reason the runtime was not loading was:

(mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64'))

Because Python is a universal binary, it is a bit unpredictable whether it is ran as arm64 or x86_64, and because .NET is available in the two flavours.... but the installed files don't seem to be marked with the architecture... that makes the whole thing a little tricky to debug.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions