{"record":{"id":"f75f6269c6a6e4f0","repo":"dotnet/runtime","slug":"option-s-missing-env-file-path","errorCode":null,"errorMessage":"Option %s: missing .env file path\n","messagePattern":"Option (.+?): missing \\.env file path\n","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/coreclr/hosts/corerun/corerun.cpp","lineNumber":843,"sourceCode":"            {\n                break;\n            }\n        }\n        else if (pal::strcmp(option, W(\"d\")) == 0 || (pal::strcmp(option, W(\"debug\")) == 0))\n        {\n            config.wait_to_debug = true;\n        }\n        else if (pal::strcmp(option, W(\"st\")) == 0)\n        {\n            config.self_test = true;\n            return true;\n        }\n        else if (pal::strcmp(option, W(\"e\")) == 0 || (pal::strcmp(option, W(\"env\")) == 0))\n        {\n            i++;\n            if (i >= argc)\n            {\n                pal::fprintf(stderr, W(\"Option %s: missing .env file path\\n\"), arg);\n                break;\n            }\n\n            std::ifstream dotenvFile{ pal::convert_to_utf8(argv[i]) };\n            config.dotenv_configuration = dotenv{ pal::string_t{ argv[i] }, dotenvFile};\n        }\n        else if ((pal::strcmp(option, W(\"?\")) == 0 || (pal::strcmp(option, W(\"h\")) == 0 || (pal::strcmp(option, W(\"help\")) == 0))))\n        {\n            display_usage();\n            break;\n        }\n        else\n        {\n            pal::fprintf(stderr, W(\"Unknown option %s\\n\"), arg);\n            break;\n        }\n    }\n","sourceCodeStart":825,"sourceCodeEnd":861,"githubUrl":"https://github.com/dotnet/runtime/blob/60108ba66eb7d1d12f595480091b4ad80a24b172/src/coreclr/hosts/corerun/corerun.cpp#L825-L861","documentation":"Printed at src/coreclr/hosts/corerun/corerun.cpp:843 when -e/--env is given as the last token (i>=argc) and no .env file path follows. corerun uses this path to load environment variables before starting the runtime.","triggerScenarios":"Triggered when `corerun -e` / `corerun --env` has no subsequent argument. parse_args increments i, finds i>=argc, prints the message and breaks.","commonSituations":"An unset $ENV_FILE variable expands to nothing, or the user assumes -e takes no value (confusing it with --env-style flags).","solutions":["Provide a path to a .env file after -e.","Ensure the file exists and is readable by corerun.","Use absolute paths to avoid CWD ambiguity in scripts."],"exampleFix":"# before\ncorerun -e MyApp.dll\n# after\ncorerun -e /app/config/.env MyApp.dll","handlingStrategy":"validation","validationCode":"// Ensure -e/--env is followed by an existing file\n#include <filesystem>\nbool env_ok(int argc, char** argv) {\n    for (int i=1;i<argc;i++) {\n        if (!strcmp(argv[i],\"-e\") || !strcmp(argv[i],\"--env\")) {\n            if (i+1>=argc) return false;\n            if (!std::filesystem::exists(argv[i+1])) return false;\n        }\n    }\n    return true;\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pass an absolute path to the .env file.","Confirm the file is readable by the corerun process.","Avoid confusing -e with environment-only flags."],"tags":["coreclr","corerun","cli","argument-parsing","dotenv"],"backgroundTag":null,"analyzedSha":"60108ba66eb7d1d12f595480091b4ad80a24b172","analyzedAt":"2026-08-10T18:54:11.478Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}