dotnet / sdk

Core functionality needed to create .NET Core projects, that is shared between Visual Studio and CLI
https://dot.net/core
MIT License
2.59k stars 1.03k forks source link

runtime is missing in global location #26052

Open Hu1buerger opened 2 years ago

Hu1buerger commented 2 years ago

Describe the bug

After installing httprepl, running $httprepl or $dotnet httprepl is failing.

To Reproduce

Install dotnet via brew and httprepl via $dotnet tool install -g Microsoft.dotnet-httprepl. Try running httprepl as described above.

Exceptions (if any)

$httprepl 
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/microsoft.dotnet-httprepl/6.0.0/microsoft.dotnet-httprepl/6.0.0/tools/net6.0/any/].
If this is a framework-dependent application, install the runtime in the global location [/usr/local/share/dotnet] 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.4
  - 
$dotnet httprepl
Could not execute because the specified command or file was not found.
Possible reasons for this include:
  * You misspelled a built-in dotnet command.
  * You intended to execute a .NET program, but dotnet-httprepl does not exist.
  * You intended to run a global tool, but a dotnet-prefixed executable with this name could not be found on the PATH.

$echo $PATH
/somevaild/.dotnet/tools /usr/local/bin /usr/bin /bin /usr/sbin /sbin /Library/TeX/texbin 

Further technical details

$dotnet --info
.NET SDK (reflecting any global.json):
 Version:   6.0.104
 Commit:    915d644e45

Runtime Environment:
 OS Name:     Mac OS X
 OS Version:  12.4
 OS Platform: Darwin
 RID:         osx.12-x64
 Base Path:   /usr/local/Cellar/dotnet/6.0.104_1/libexec/sdk/6.0.104/

Host (useful for support):
  Version: 6.0.4
  Commit:  be98e88c76

.NET SDKs installed:
  6.0.104 [/usr/local/Cellar/dotnet/6.0.104_1/libexec/sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 6.0.4 [/usr/local/Cellar/dotnet/6.0.104_1/libexec/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 6.0.4 [/usr/local/Cellar/dotnet/6.0.104_1/libexec/shared/Microsoft.NETCore.App]

To install additional .NET runtimes or SDKs:
  https://aka.ms/dotnet-download
dotnet-issue-labeler[bot] commented 2 years ago

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.

Hu1buerger commented 2 years ago

This might be related to this previous but similar issue #25767.

Hu1buerger commented 2 years ago

as described in #12359 i set DOTNET_ROOT $(dirname $(realpath $(which dotnet))) with no luck.

joeloff commented 2 years ago

This isn't an M1 running x64 code is it? I've seen a number of issues like this one

https://stackoverflow.com/questions/70273658/a-fatal-error-occurred-the-required-library-libhostfxr-dylib-could-not-be-found

Hu1buerger commented 2 years ago

@joeloff unfortunately not. It's an Intel Mac

vitek-karas commented 2 years ago

This feels like something didn't work correctly in the brew install of .NET. Per the dotnet --info the install is located in /usr/local/Cellar/dotnet/6.0.104_1/libexec, but based on the errors it's not registered. So apphost won't be able to find it since it's not on the default path nor is it registered.

I don't have a mac at hand to try this - to verify that brew is not doing the right thing here. @joeloff could you please check on this? I assume we don't own the brew .NET package, right?

A workaround is either:

For those interested, details on how the install location works and what is used to find it are here: https://github.com/dotnet/designs/blob/main/accepted/2021/install-location-per-architecture.md

Hu1buerger commented 1 year ago

@vitek-karas afaik brew just runs the default installer see here

vitek-karas commented 1 year ago

I honestly don't know, but something had to install the runtime into /usr/local/Cellar/dotnet/6.0.104_1/libexec - it's definitely not its default location. Based on internet search the /usr/local/Cellar is the location into which brew installs software. It then links to it from the usual locations. But depending on how it does that either the brew or the package need to know about this in the case of runtime, since it needs to register that location in the /etc/dotnet/install_location_x64 (in the case of the x64 architecture).

@joeloff @ericstj - do one of you know if we tested runtime/sdk packages with brew?

ericstj commented 1 year ago

Not certain, but the installer's postinstall script doesn't hardcode the path. It gets it from the installation engine: https://github.com/dotnet/runtime/blob/cae954add0f01c85de7fef8cc41c2a11d1c920e1/src/installer/pkg/sfx/installers/osx_scripts/host/postinstall#L8

vitek-karas commented 1 year ago

@Hu1buerger could you please grab a host trace of the failure?

export COREHOST_TRACE=1
export COREHOST_TRACEFILE=host.txt
--- run the tool which fails

Then share the host.txt - please be aware that the file contains local file paths, environment and other pieces of information about the machine and its state. Make sure you're OK sharing this publicly.

Hu1buerger commented 1 year ago

@vitek-karas host.txt

FYI: I uninstalled dotnet and installed dotnet manually.

vitek-karas commented 1 year ago

Thanks, the shared host.txt doesn't show anything unusual - normal default .NET install, seems to work.

GyroJoe commented 1 year ago

The Formula mentions this, but you need to set DOTNET_ROOT properly: export DOTNET_ROOT="$HOMEBREW_PREFIX/opt/dotnet/libexec"

Here's the hosts.txt output without this for completeness:

Tracing enabled @ Wed Mar  8 00:53:35 2023 UTC
--- Invoked apphost [version: 7.0.0, commit hash: d099f075e45d2aa6007a22b71b45a08758559f80] main = {
authcore
}
The managed DLL bound to this executable is: '.store/authenticatorcore/0.1.0-ci-20230308-004036/authenticatorcore/0.1.0-CI-20230308-004036/tools/net7.0/any/AuthenticatorCore.dll'
Looking for architecture-specific install_location file in '/etc/dotnet/install_location_arm64'.
Found registered install location '/usr/local/share/dotnet'.
Using global installation location [/usr/local/share/dotnet] as runtime location.
The required library libhostfxr.dylib could not be found. Searched with root path [/Users/joeflint/.dotnet/tools/.store/authenticatorcore/0.1.0-ci-20230308-004036/authenticatorcore/0.1.0-ci-20230308-004036/tools/net7.0/any/], environment variable [DOTNET_ROOT], default install location [/usr/local/share/dotnet], self-registered config location [/etc/dotnet/install_location_arm64]
You must install .NET to run this application.

App: /Users/joeflint/.dotnet/tools/authcore
Architecture: arm64
App host version: 7.0.0
.NET location: Not found

Learn about runtime installation:
https://aka.ms/dotnet/app-launch-failed

Download the .NET runtime:
https://aka.ms/dotnet-core-applaunch?missing_runtime=true&arch=arm64&rid=osx.13-arm64&apphost_version=7.0.0