dotnet/runtime · error

Option : missing .env file path

Error message

Option %s: missing .env file path

What it means

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.

Solutions

  1. Provide a path to a .env file after -e.
  2. Ensure the file exists and is readable by corerun.
  3. Use absolute paths to avoid CWD ambiguity in scripts.

Example fix

# before
corerun -e MyApp.dll
# after
corerun -e /app/config/.env MyApp.dll
Defensive patterns

Strategy: validation

Validate before calling

// Ensure -e/--env is followed by an existing file
#include <filesystem>
bool env_ok(int argc, char** argv) {
    for (int i=1;i<argc;i++) {
        if (!strcmp(argv[i],"-e") || !strcmp(argv[i],"--env")) {
            if (i+1>=argc) return false;
            if (!std::filesystem::exists(argv[i+1])) return false;
        }
    }
    return true;
}

Prevention

When it happens

Trigger: Triggered when `corerun -e` / `corerun --env` has no subsequent argument. parse_args increments i, finds i>=argc, prints the message and breaks.

Common situations: An unset $ENV_FILE variable expands to nothing, or the user assumes -e takes no value (confusing it with --env-style flags).

Related errors


AI-assisted analysis of dotnet/runtime@60108ba66e (2026-08-10). Data as JSON: /api/errors/f75f6269c6a6e4f0. Report an issue: GitHub.

Appendix: source

Thrown at src/coreclr/hosts/corerun/corerun.cpp:843

            {
                break;
            }
        }
        else if (pal::strcmp(option, W("d")) == 0 || (pal::strcmp(option, W("debug")) == 0))
        {
            config.wait_to_debug = true;
        }
        else if (pal::strcmp(option, W("st")) == 0)
        {
            config.self_test = true;
            return true;
        }
        else if (pal::strcmp(option, W("e")) == 0 || (pal::strcmp(option, W("env")) == 0))
        {
            i++;
            if (i >= argc)
            {
                pal::fprintf(stderr, W("Option %s: missing .env file path\n"), arg);
                break;
            }

            std::ifstream dotenvFile{ pal::convert_to_utf8(argv[i]) };
            config.dotenv_configuration = dotenv{ pal::string_t{ argv[i] }, dotenvFile};
        }
        else if ((pal::strcmp(option, W("?")) == 0 || (pal::strcmp(option, W("h")) == 0 || (pal::strcmp(option, W("help")) == 0))))
        {
            display_usage();
            break;
        }
        else
        {
            pal::fprintf(stderr, W("Unknown option %s\n"), arg);
            break;
        }
    }

View on GitHub (pinned to 60108ba66e)