Skip to content

Adding extra info about error when hostfxr not found or loaded properly. #76

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions clr_loader/ffi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,20 @@ def load_hostfxr(dotnet_root: Path):
hostfxr_path = dotnet_root / "host" / "fxr"
hostfxr_paths = hostfxr_path.glob(f"?.*/{hostfxr_name}")

error_report = list()

for hostfxr_path in reversed(sorted(hostfxr_paths, key=_path_to_version)):
try:
return ffi.dlopen(str(hostfxr_path))
except Exception:
pass
except Exception as err:
error_report.append(f"Path {hostfxr_path} gave the following error:\n{err}")

try:
return ffi.dlopen(str(dotnet_root / hostfxr_name))
except Exception:
pass
except Exception as err:
error_report.append(f"Path {hostfxr_path} gave the following error:\n{err}")

raise RuntimeError(f"Could not find a suitable hostfxr library in {dotnet_root}")
raise RuntimeError(f"Could not find a suitable hostfxr library in {dotnet_root}. The following paths were scanned:\n\n"+("\n\n".join(error_report)))


def load_mono(path: Optional[Path] = None):
Expand Down