{"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":"warning","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/290d5ab72cc1102813fbc0406fb186ceadabc340/src/coreclr/hosts/corerun/corerun.cpp#L825-L861","documentation":"Printed by parse_args() when -e / --env is the LAST token (i >= argc after i++). The option expects a path to a .env file whose variables corerun will load_into_current_process(). None follows. Parsing breaks and returns false.","triggerScenarios":"User runs 'corerun -e' with no path after. The dotenv file is later loaded via config.dotenv_configuration.load_into_current_process() inside run().","commonSituations":"Forgotten .env path; trailing -e; meant to use shell 'source .env' instead.","solutions":["Supply the .env file path: 'corerun -e ./.env App.dll'.","Ensure the file is readable; it is opened with std::ifstream in UTF-8.","Drop -e and export the variables directly in the shell if simpler."],"exampleFix":"# before\ncorerun -e App.dll\n# after\ncorerun -e ./config/.env App.dll","handlingStrategy":"validation","validationCode":"# ensure -e/--env is never the trailing token\nif [ \"${@: -1}\" = \"-e\" ] || [ \"${@: -1}\" = \"--env\" ]; then\n  echo '-e requires a following .env file path'; exit 2\nfi","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always follow -e with a readable .env file path.","Prefer exporting variables in the shell if you only need a couple.","Confirm the file is UTF-8 (opened with std::ifstream)."],"tags":["coreclr","corerun","cli","argument-parsing","dotenv","env"],"analyzedSha":"290d5ab72cc1102813fbc0406fb186ceadabc340","analyzedAt":"2026-08-06T19:57:01.276Z","schemaVersion":2},"datasetVersion":"2026-08-06T23:17:07.152Z"}