4

I'm trying to install dotenet ef on Ubuntu 20.4.1 LTS.

First, I've installed the tool globally:

dotnet tool install --global dotnet-ef

As it was not working, then I added this PATH reference to my dotnet tools folder on my .bashrc file:

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

As suggested here: Cannot find command 'dotnet ef'?

Yet when I try to run dotnet ef, I get this error message:

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.

Interestingly if I try to install it again I'm informed it is already installed.

Tool 'dotnet-ef' is already installed.

But if I try to list my installed tools with dotnet tool list I get an empty result:

Tool 'dotnet-ef' is already installed.

I have also checked my ~/.dotnet/tools/ folder and it is empty.

What am I missing here?

Rogerio Schmitt
  • 1,055
  • 1
  • 15
  • 35
  • Did you use `snap install` to install the dotnet sdk? If so, try `sudo snap alias dotnet-sdk.dotnet dotnet`. Might not help but will at least narrow down the problem – jdewerth Dec 12 '20 at 22:32
  • @jandrew I'm not sure if I did. Is there any way I can be sure if I did it or not? – Rogerio Schmitt Dec 12 '20 at 23:31
  • Well, how did you install the .NET SDK on your Ubuntu machine? I'm guessing it was either through one of the package managers (`sudo apt-get`, etc.) or you manually installed it? – jdewerth Dec 12 '20 at 23:50
  • I can't remember how I did it, is there any way I can check on how it was? – Rogerio Schmitt Dec 13 '20 at 00:03

3 Answers3

3

Found the solution.

Add the following to the .bashrc/.zshrc

export PATH="$PATH:$HOME/.dotnet/tools/"
Dzmitry Atkayey
  • 332
  • 5
  • 12
2

I had the same problem on Ubuntu. I had installed dotnet manually. For some reason dotnet-ef looks for dotnet in "/usr/share/dotnet". So I had to install the dotnet-sdk exactly in the directory "/usr/share/dotnet", change the PATH accordingly and also set DOTNET_ROOT to this directory. Then dotnet-ef also worked.

Btw: You can set the installation path of dotnet-ef manually by --tool-path "$HOME/.dotnet/tools" if --global does not work.

  • 1
    This lead me to finding I had a /usr/share/dotnet that was empty and recreating it as a symlink to my $HOME/.dotnet folder – rob Oct 19 '22 at 10:27
0

While using Fish, use fish_add_path $HOME/.dotnet/tools/ after installing ef globally.

Andre Morata
  • 307
  • 3
  • 12