Home > Blockchain >  zsh: command not found: dotnet-ef
zsh: command not found: dotnet-ef

Time:11-10

I am using asp.net core 2.1 with visual studio code or rider in mac. I already have a 2.1 sdk install on mac, while using the below command

dotnet-ef database update --project XXXX.XXXX

I get an exception as

zsh: command not found: dotnet-ef

Using the command

dotnet tool install --global dotnet-ef

getting an exception as Tool 'dotnet-ef' is already installed.

Then using this command dotnet tool restore

error NU3037: Package 'dotnet-ef 3.1.1' from source 'https://api.nuget.org/v3/index.json': The repository countersignature validity period has expired.

Package "dotnet-ef" failed to restore, due to Microsoft.DotNet.ToolPackage.ToolPackageException: The tool package could not be restored.

CodePudding user response:

For mac I need to export the below path

export PATH="$PATH:$HOME/.dotnet/tools/"

CodePudding user response:

Yes, give an example of the error:

$ dotnet ef
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 Core program, but dotnet-ef 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.

The second and third refer to dotnet trying to find a dotnet-ef command but it cannot find it. As the third point said, dotnet-ef is not on your way.

This is what the documentation says:

Global tools can be installed in the default directory or in a specific location. The default directory is:

OS Path

Linux/macOS $HOME/.dotnet/tools

Windows %USERPROFILE%\.dotnet\tools

So, you should add $HOME/.dotnet/tools/ to your $PATH.

For Linux and macOS, add a line to the shell configuration:

bash/ zsh:

export PATH="$PATH:$HOME/.dotnet/tools/"

When you start a new shell/terminal (or next time you log in) dotnet ef should work.

For Windows:

You need to add %USERPROFILE%.dotnet\tools to PATH.

  • Related