Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The required library libhostfxr.so could not be found. Netcore Linux

 ❯ dotnet ef   
A fatal error occurred. The required library libhostfxr.so could not be found.
If this is a self-contained application, that library should exist in [/home/ru/.dotnet/tools/.store/dotnet-ef/6.0.2/dotnet-ef/6.0.2/tools/netcoreapp3.1/any/].
If this is a framework-dependent application, install the runtime in the global location [/usr/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=arch-x64&apphost_version=6.0.2

~ 

dotnet ef not working After running the command is not working so what can I do?

like image 616
Raúl Peñate Avatar asked Oct 31 '25 04:10

Raúl Peñate


2 Answers

Solved by adding this in whatever part of shell profile (it can be at the end):

# Netcore
export PATH=$PATH:$HOME/.dotnet/tools
export DOTNET_ROOT=$HOME/.dotnet
export PATH=$PATH:$DOTNET_ROOT

Your shell profile can be in one of these files:

  • Bash Shell: ~/.bash_profile, ~/.bashrc
  • Korn Shell: ~/.kshrc or .profile
  • Z Shell: ~/.zshrc or .zprofile

Don't forget to use the command source ~/.bashrc (depending on your shell profile) for e.g, so env variables can load.

More here

To check if everything is ok run dotnet ef, you should get something like this:

❯ dotnet ef

                     _/\__       
               ---==/    \\      
         ___  ___   |.    \|\    
        | __|| __|  |  )   \\\   
        | _| | _|   \_/ |  //|\\ 
        |___||_|       /   \\\/\\

Entity Framework Core .NET Command-line Tools 6.0.2

Usage: dotnet ef [options] [command]

Options:
  --version        Show version information
  -h|--help        Show help information
  -v|--verbose     Show verbose output.
  --no-color       Don't colorize output.
  --prefix-output  Prefix output with level.

Commands:
  database    Commands to manage the database.
  dbcontext   Commands to manage DbContext types.
  migrations  Commands to manage migrations.

Use "dotnet ef [command] --help" for more information about a command.
like image 135
Raúl Peñate Avatar answered Nov 02 '25 22:11

Raúl Peñate


I got this error (and many others) while using the Snap version. These problems all went away when I switched to the package manager version.

like image 23
CrazyPyro Avatar answered Nov 02 '25 23:11

CrazyPyro



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!