{"record":{"id":"9840cdd3d1b06093","repo":"abpframework/abp","slug":"appsettings-file-could-not-be-found-path-setting","errorCode":null,"errorMessage":"appsettings file could not be found. Path:{settingsFilePath}","messagePattern":"appsettings file could not be found\\. Path:(.+?)","errorType":"exception","errorClass":"FileNotFoundException","httpStatus":null,"severity":"error","filePath":"framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Configuration/ConfigReader.cs","lineNumber":18,"sourceCode":"﻿using System.IO;\nusing System.Text.Json;\nusing System.Text.Json.Serialization;\nusing Volo.Abp.DependencyInjection;\n\nnamespace Volo.Abp.Cli.Configuration;\n\npublic class ConfigReader : IConfigReader, ITransientDependency\n{\n    const string appSettingFileName = \"appsettings.json\";\n\n    public AbpCliConfig Read(string directory)\n    {\n        var settingsFilePath = Path.Combine(directory, appSettingFileName);\n\n        if (!File.Exists(settingsFilePath))\n        {\n            throw new FileNotFoundException($\"appsettings file could not be found. Path:{settingsFilePath}\");\n        }\n\n        var settingsFileContent = File.ReadAllText(settingsFilePath);\n\n        var documentOptions = new JsonDocumentOptions\n        {\n            CommentHandling = JsonCommentHandling.Skip\n        };\n\n        using (var document = JsonDocument.Parse(settingsFileContent, documentOptions))\n        {\n            if (document.RootElement.TryGetProperty(\"AbpCli\", out var element))\n            {\n                var configJson = element.GetRawText();\n                var options = new JsonSerializerOptions\n                {\n                    Converters =\n                        {","sourceCodeStart":1,"sourceCodeEnd":36,"githubUrl":"https://github.com/abpframework/abp/blob/7ed43b1931b9df46a50c0c59148a18645641d0df/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Configuration/ConfigReader.cs#L1-L36","documentation":"Thrown by `ConfigReader.Read` when it cannot find `appsettings.json` in the supplied directory. Unlike most CLI errors this is a raw `FileNotFoundException` (not `CliUsageException`), so it surfaces as an unhandled exception. `ConfigReader` supplies CLI configuration such as proxy/API keys.","triggerScenarios":"The CLI's configuration loader is invoked with a directory that lacks `appsettings.json`, e.g. the ABP CLI tool directory, a fresh checkout, or a directory where the file was removed.","commonSituations":"Custom tooling that calls `ConfigReader.Read` directly with a wrong path; the CLI installed as a global tool whose directory is missing the default `appsettings.json`; permissions preventing the file from being read (the `File.Exists` returns false).","solutions":["Ensure `appsettings.json` exists in the directory passed to `ConfigReader.Read` (create an empty `{}` if you only need defaults).","If calling from code, pass the correct base directory (e.g. `AppContext.BaseDirectory`).","Reinstall/repair the ABP CLI global tool so its `appsettings.json` is restored: `dotnet tool uninstall -g Volo.Abp.Cli && dotnet tool install -g Volo.Abp.Cli`."],"exampleFix":"// before\nvar config = new ConfigReader().Read(\"/wrong/path\");\n// after\nvar dir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);\nif (!File.Exists(Path.Combine(dir, \"appsettings.json\")))\n    File.WriteAllText(Path.Combine(dir, \"appsettings.json\"), \"{}\");\nvar config = new ConfigReader().Read(dir);","handlingStrategy":"try-catch","validationCode":"var dir = AppContext.BaseDirectory;\nvar settingsPath = Path.Combine(dir, \"appsettings.json\");\nif (!File.Exists(settingsPath))\n    File.WriteAllText(settingsPath, \"{}\"); // defaults\nvar config = new ConfigReader().Read(dir);","typeGuard":null,"tryCatchPattern":"AbpCliConfig config;\ntry { config = new ConfigReader().Read(dir); }\ncatch (FileNotFoundException ex) when (ex.FileName?.Contains(\"appsettings\") == true)\n{\n    logger.LogWarning(\"appsettings.json missing in {Dir}; using default config.\", dir);\n    config = new AbpCliConfig();\n}","preventionTips":["Ship a default `appsettings.json` next to the CLI tool.","Pass `AppContext.BaseDirectory` rather than relative paths to ConfigReader.","If writing tooling on top, fall back to an empty config when the file is absent."],"tags":["cli","configuration","appsettings","file-not-found"],"backgroundTag":null,"analyzedSha":"7ed43b1931b9df46a50c0c59148a18645641d0df","analyzedAt":"2026-08-13T16:26:11.351Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}