`dotnet tool install` doesn't understand multi-arch systems or TFM requirements
See original GitHub issueA user of the .NET global tool vsmac-cli reported the following host error when trying to use the tool after installing it.
% vsmac
A fatal error occurred. The required library libhostfxr.dylib could not be found.
If this is a self-contained application, that library should exist in [/Users/[USER]/.dotnet/tools/.store/vsmac-cli/0.2.0/vsmac-cli/0.2.0/tools/net5.0/any/].
If this is a framework-dependent application, install the runtime in the global location [/usr/local/share/dotnet/x64] or use the DOTNET_ROOT environment variable to specify the runtime location or register the runtime location in [/etc/dotnet].
The .NET runtime can be found at:
- https://aka.ms/dotnet-core-applaunch?missing_runtime=true&arch=x64&rid=osx.12-x64&apphost_version=6.0.3
This error occurred because the app is framework dependent and the end user does not have the required framework installed. This is likely a common scenario for end users, yet the message is needlessly complex, with implementation details (libhostfxr) and irrelevant information (self-contained vs shared) that appears to be targeted at the developer of the app. This provided URL also appears to be incorrect, as the app’s manifest does not allow it to be run with 6.x.
I would suggest that the error be more specifically targeted at helping end users understand the problem and resolve it e.g. something like
This application depends on version 5.0.x of the shared .NET runtime, which is not installed on this machine.
The latest compatible version of the runtime can be found at https://aka.ms/dotnet-runtime?version=5.0&rollforward=minor&rid=osx.12-x64
Perhaps dotnet-tool
could also detect the missing runtime and prompt users to install it upfront when installing the tool.
Issue Analytics
- State:
- Created a year ago
- Reactions:1
- Comments:36 (33 by maintainers)
Top GitHub Comments
I ran into this (or some subset of it) today. I think some of this is new information; I hope it’s useful.
I got into the situation originally with SDK 6.0.300 (6.0.5 runtime), but it’s reproducible with the latest as of today—7.0.200 (7.0.3 runtime). I’m on an M1 Mac (arm64), and this was my experience:
The instructions at the
app-launch-failed
URL just told me to install the .NET runtime, which I’d already done. I’d used the installer, so it should have been in the expected place, etc.It took me a while to notice the
x64
in that output, and realize that it wasn’t complaining about the version (though when I first ran it, I didn’t have 7.0 installed, so it was probably complaining about that, too), but the architecture.What I didn’t see mentioned in the discussion above was the
--arch
flag todotnet install
:The original discussion here is from some time ago, and I’m sure things have changed a bit since then, but it seems like much of the discussion has been about whether the tool is available at all for ARM64. But that certainly doesn’t seem to be my problem. Instead, it looks like even when there is a choice, the installer makes the wrong one.
dotnet --info
@akoeplinger I think the problem with global tools should not be solved in the host - host is for all apps, lot of the above problems are relatively specific to global tools. Also things like roll-forward are very focused on developers, the host needs to target “normal users” - so anything more complicated than “Please visit this URL” is probably too much (and yes, the current experience is unfortunately already too much).
I think the core of the problem is that
dotnet tool install
makes several assumptions which are problematic to say the least:I personally don’t know much about the
dotnet tool install
to be honest, but lot of the above assumptions seem to be part of the system in some way or form. And some of them are simply not viable for the tools we want to use this for.I think the solution to this would start by having a clear declaration of the requirements for a given tool and the
dotnet tool install
validating such requirements. This can be .NET version, architecture and many more. Ideally thedotnet tool install
would also be able to fix some of these - like installing new/older version of the runtime, installing different architecture, …Basically
dotnet tool install
tries to act a little like a package manager - without implementing most of the complexities which come with it.