{"record":{"id":"433273f49e41a080","repo":"microsoft/aspire","slug":"the-installed-foundry-cli-does-not-expose-a-server-or","errorCode":null,"errorMessage":"The installed Foundry CLI does not expose a 'server' or 'service' command. Update Foundry Local and ensure the 'foundry' command on PATH is the expected installation.","messagePattern":"The installed Foundry CLI does not expose a 'server' or 'service' command\\. Update Foundry Local and ensure the 'foundry' command on PATH is the expected installation\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Aspire.Hosting.Foundry/FoundryLocalService.cs","lineNumber":576,"sourceCode":"    }\n\n    internal static string DetermineDaemonVerb(string helpOutput)\n    {\n        // Old CLI help lists:\n        //   service  Commands to start and stop the Foundry Local service\n        // New CLI help lists:\n        //   server   Start, stop, restart, inspect, and troubleshoot the local Foundry daemon\n        if (Regex.IsMatch(helpOutput, @\"(?im)^\\s*(?:Server:\\s*)?server(?:\\s|$)\"))\n        {\n            return \"server\";\n        }\n\n        if (Regex.IsMatch(helpOutput, @\"(?im)^\\s*service(?:\\s|$)\"))\n        {\n            return \"service\";\n        }\n\n        throw new InvalidOperationException(\"The installed Foundry CLI does not expose a 'server' or 'service' command. Update Foundry Local and ensure the 'foundry' command on PATH is the expected installation.\");\n    }\n\n    internal static bool TryParseServerEndpoint(string output, out Uri endpoint)\n    {\n        // Current CLI JSON output:\n        //   {\"running\":true,\"webUrls\":[\"http://127.0.0.1:55829\"],\"port\":55829}\n        try\n        {\n            using var document = JsonDocument.Parse(output);\n            if (document.RootElement.TryGetProperty(\"webUrls\", out var webUrls) &&\n                webUrls.ValueKind is JsonValueKind.Array &&\n                webUrls.GetArrayLength() > 0 &&\n                Uri.TryCreate(webUrls[0].GetString(), UriKind.Absolute, out var parsedEndpoint))\n            {\n                endpoint = EnsureTrailingSlash(parsedEndpoint);\n                return true;\n            }\n        }","sourceCodeStart":558,"sourceCodeEnd":594,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Hosting.Foundry/FoundryLocalService.cs#L558-L594","documentation":"FoundryLocalService needs to invoke the Foundry Local daemon, but different CLI versions name that subcommand differently ('service' in old versions, 'server' in new ones). At startup the library runs `foundry --help` and inspects the help text to pick the right verb. If neither 'server' nor 'service' appears in the help output, it throws this InvalidOperationException because it cannot control the daemon at all.","triggerScenarios":"DetermineDaemonVerb is called by GetDaemonVerbAsync with the output of `foundry --help`; the regexes `^\\s*(?:Server:\\s*)?server(?:\\s|$)` and `^\\s*service(?:\\s|$)` both fail to match, typically because the `foundry` binary found on PATH is a different tool, a stub/shim, or a Foundry Local build whose help output omits both commands.","commonSituations":"Running the Aspire AppHost on a machine where Foundry Local is not installed so an unrelated 'foundry' executable shadows the real one on PATH; an outdated Foundry Local version whose help text does not list 'service'; a partially updated or broken install; localized or restructured CLI help output that no longer matches the expected patterns.","solutions":["Install or update Foundry Local to a current version (e.g. via `pip install foundry-local` or the official installer) so the CLI exposes the daemon command","Verify which binary resolves with `which foundry` / `Get-Command foundry` and remove or reorder a shadowing entry on PATH","Run `foundry --help` manually and confirm a 'server' or 'service' line appears in the command list","Reinstall Foundry Local cleanly if the help output is truncated or corrupted"],"exampleFix":"// before: 'foundry' on PATH is the wrong tool\n$ foundry --help  # no 'server' or 'service' command listed\n// after: install the real Foundry Local so it shadows the wrong binary\n$ pip install -U foundry-local\n$ foundry --help  # help now lists: server  Start, stop, restart, inspect...","handlingStrategy":"validation","validationCode":"// Before running the AppHost, verify the CLI can drive the daemon:\nvar psi = new ProcessStartInfo(\"foundry\", \"--help\") { RedirectStandardOutput = true };\nusing var p = Process.Start(psi)!;\nvar help = await p.StandardOutput.ReadToEndAsync();\nbool ok = Regex.IsMatch(help, @\"(?im)^\\s*(?:Server:\\s*)?server(?:\\s|$)\")\n       || Regex.IsMatch(help, @\"(?im)^\\s*service(?:\\s|$)\");\nif (!ok) { /* fix PATH / install Foundry Local before launching */ }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pin a recent Foundry Local version in your dev environment setup docs","Add `foundry --help | grep -E 'server|service'` to a preflight check or CI smoke test","Keep the real Foundry Local install ahead of any shadowing 'foundry' binary on PATH"],"tags":["foundry","cli","external-tool","local-development"],"backgroundTag":"command-not-found","analyzedSha":"25830f84bd145686607ad00c057b3f84e2e51d43","analyzedAt":"2026-09-16T11:10:06.193Z","contentChangedAt":"2026-09-16T11:10:06.193Z","schemaVersion":2},"datasetVersion":"2026-09-21T04:17:39.646Z"}