"zsh: command not found: dotnet-svcutil" after upgrading to macOS Catalina

Viewed 3025

After upgrading my macOS to 10.15 (Catalina) and switching from bash to zsh, as recommended, I'm trying to start svcutil (or any of the other .NET Core tools) from Terminal, but I'm getting the following error message:

zsh: command not found: dotnet-svcutil

Strange, since its location (~/.dotnet/tools, where .NET Core tools are installed by default) is mentioned when checking the path with echo $PATH. How can I solve this?

2 Answers

As mentioned here, zsh doesn't support ~ in paths. The path entry for the .NET Core tools is added during installation as a file /etc/paths.d/dotnet-cli-tools with path entry ~/.dotnet/tools. Changing that to $HOME/.dotnet/tools or ${HOME}/.dotnet/tools didn't help, but changing it to the actual path (e.g. /Users/Glorfindel/.dotnet/tools) did the trick.

Another option is to reinstall the tool, e.g. with

dotnet tool uninstall --global dotnet-svcutil
dotnet tool install --global dotnet-svcutil

The installation program will tell you the following, which I haven't tried:

Tools directory '/Users/Glorfindel/.dotnet/tools' is not currently on the PATH environment variable.
If you are using zsh, you can add it to your profile by running the following command:

cat << \EOF >> ~/.zprofile
# Add .NET Core SDK tools
export PATH="$PATH:/Users/Glorfindel/.dotnet/tools"
EOF

And run zsh -l to make it available for current session.

You can only add it to the current session by running the following command:

export PATH="$PATH:/Users/Glorfindel/.dotnet/tools"

I had a similar problem, and fixed it by doing the following from Terminal:

copy the contents of ~/.bash_profile to ~/.zshrc

  1. open one terminal window and type nano ~/.bash_profile
  2. select the code in that file and copy it
  3. open another terminal window and type nano ~/.zshrc
  4. paste and save the file

Re-open VSCode and it should work. It worked for me!

Related