Skip to content

func init returns No templates or subcommands found matching: 'func'. #4399

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
lilyjma opened this issue Apr 30, 2025 · 5 comments
Open

func init returns No templates or subcommands found matching: 'func'. #4399

lilyjma opened this issue Apr 30, 2025 · 5 comments

Comments

@lilyjma
Copy link
Contributor

lilyjma commented Apr 30, 2025

Version

4.0.7030

Description

I have core tools version 4.0.7030, which I believe is the latest. I'm trying to run func init LocalFunctionProj --worker-runtime dotnet-isolated --docker --target-framework net8.0. The command returns

No templates or subcommands found matching: 'func'.
Did you mean one of the following templates?
   dotnet new sln
   dotnet new mvc
   dotnet new grpc
   dotnet new nunit
   dotnet new xunit

To list installed templates similar to 'func', run:
   dotnet new list func
To search for the templates on NuGet.org, run:
   dotnet new search func


For details on the exit code, refer to https://aka.ms/templating-exit-codes#103

Error creating project template

I've tried resintalling core tools, but still experiencing the same issue.

Also tried just running func init, but ran into the same error.

Running func --version returns the version, so it's strange to me why func isn't recognized.

Steps to reproduce

Create a new function project using func init and core tools version 4.0.7030

@mattchenderson
Copy link
Contributor

After debugging with Lily, we determined that this was an issue with .NET 9.0.202. This is on an M1 Mac, with the Core Tools initially installed through Homebrew (though also reproduced with an npm installation).

The root of this seems to be how the .NET templating engine is handling the path. We observed the following when attempting to run the same command that the Core Tools was (via the --debug flag):

dotnet new --install "/usr/local/Cellar/azure-functions-core-tools@4/4.0.7030/templates/net-isolated/projectTemplates.4.0.5051.nupkg" -v diag
[2025-05-01 16:21:19.535] [Debug] [Template Engine] => [Execute]: Execute started
Warning: use of 'dotnet new --install' is deprecated. Use 'dotnet new install' instead.
For more information, run:
   dotnet new install -h


[2025-05-01 16:21:19.539] [Debug] [Microsoft.TemplateEngine.Edge.TemplateConstraintManager] => [Execute]: Found 5 constraints factories, initializing.
[2025-05-01 16:21:19.540] [Debug] [MSBuildEvaluator] => [Execute]: Output directory is: /usr/local/Cellar/azure-functions-core-tools@4/4.0.7030/templates/net-isolated.
[2025-05-01 16:21:19.540] [Debug] [MSBuildEvaluator] => [Execute]: Project full path is: <null>.
[2025-05-01 16:21:19.542] [Debug] [MSBuildEvaluator] => [Execute]: Found project files: .
[2025-05-01 16:21:19.542] [Debug] [MSBuildEvaluator] => [Execute]: No project found.
The following template packages will be installed:
   /usr/local/Cellar/azure-functions-core-tools::4/4.0.7030/templates/net-isolated/projectTemplates.4.0.5051.nupkg


[2025-05-01 16:21:19.601] [Debug] [Microsoft.TemplateEngine.Edge.Installers.NuGet.NuGetInstaller] => [Execute]: /usr/local/Cellar/azure-functions-core-tools is not a local NuGet package.
[2025-05-01 16:21:19.602] [Debug] [Microsoft.TemplateEngine.Edge.Installers.NuGet.NuGetInstaller] => [Execute]: /usr/local/Cellar/azure-functions-core-tools is not a valid NuGet package ID.
[2025-05-01 16:21:19.602] [Debug] [Microsoft.TemplateEngine.Edge.Installers.NuGet.NuGetInstaller] => [Execute]: 4/4.0.7030/templates/net-isolated/projectTemplates.4.0.5051.nupkg is not a valid NuGet package version.
/usr/local/Cellar/azure-functions-core-tools::4/4.0.7030/templates/net-isolated/projectTemplates.4.0.5051.nupkg is not supported.


[2025-05-01 16:21:19.628] [Debug] [Template Engine] => [Execute]: Execute finished, took 93 ms
For details on the exit code, refer to https://aka.ms/templating-exit-codes#106

Notably, the @ symbol from the original path seems to be replaced with ::, and then the system seems to be splitting along that. If we moved to that directory and used a relative path, the installation worked as expected. The package then was described with :: separating the package name and the version, which aligns with what we see here.

We also reset the state there and uninstalled .NET SDK 9.0.202, meaning a .NET 8 version was engaged. That also worked.

Using a Mac M2, I see the following:

.NET SDK version Behavior
9.0.102 No repro - works as expected
9.0.200 Observed issue
9.0.202 Observed issue
9.0.203 (latest) Observed issue

This feels like a .NET SDK problem that has not yet been addressed. I'll need to look to see if this has already been reported somewhere and link things together there.

@mattchenderson
Copy link
Contributor

I did a diagnostic trace using 9.0.102 as well, and that preserves the @. Relevant sequence:

dotnet new install "/opt/homebrew/Cellar/azure-functions-core-tools@4/4.0.7030/templates/net-isolated/projectTemplates.4.0.5051.nupkg" -v diag   
[2025-05-01 16:01:20.818] [Debug] [Template Engine] => [Execute]: Execute started
[2025-05-01 16:01:20.820] [Debug] [Microsoft.TemplateEngine.Edge.TemplateConstraintManager] => [Execute]: Found 5 constraints factories, initializing.
[2025-05-01 16:01:20.821] [Debug] [MSBuildEvaluator] => [Execute]: Output directory is: /Users/mch/Downloads/ctrepro.
[2025-05-01 16:01:20.821] [Debug] [MSBuildEvaluator] => [Execute]: Project full path is: <null>.
[2025-05-01 16:01:20.822] [Debug] [MSBuildEvaluator] => [Execute]: Found project files: .
[2025-05-01 16:01:20.822] [Debug] [MSBuildEvaluator] => [Execute]: No project found.
The following template packages will be installed:
   /opt/homebrew/Cellar/azure-functions-core-tools@4/4.0.7030/templates/net-isolated/projectTemplates.4.0.5051.nupkg


[2025-05-01 16:01:20.866] [Debug] [Microsoft.TemplateEngine.Edge.Installers.NuGet.NuGetInstaller] => [Execute]: /opt/homebrew/Cellar/azure-functions-core-tools@4/4.0.7030/templates/net-isolated/projectTemplates.4.0.5051.nupkg is identified as the local NuGet package.

@mattchenderson
Copy link
Contributor

See the item on the .NET SDK repo for the underlying .NET issue. This work item should be to address that the Core Tools swallows the error and doesn't present it to the user, moving on to the attempted scaffolding operation and only showing an error there.

@badsyntax
Copy link

Just chiming in to confirm, seeing this issue on my M1 Mac using 9.0.200. A quick workround is to:

  1. dotnet new globaljson
  2. Edit global.json, change sdk version to eg 8.0.203 or 9.0.102
  3. func init myproject --worker-runtime dotnet-isolated --docker --target-framework net9.0

@earloc
Copy link

earloc commented May 26, 2025

Same here, M3 Mac on dotnet 9.0.203 / func 4.0.7030. Using above workaround (setting to 8.0.408 in global.json) did the trick.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants