karatelabs/karate · error · RuntimeException

Failed to load config from

Error message

Failed to load config from: <configPath>

What it means

KaratePom.load(configPath) reads the karate-pom.json file from disk and parses it; any IO or parse failure is wrapped in 'Failed to load config from: <path>' with the original exception as cause. Typically the file does not exist or is unreadable.

Solutions

  1. Verify the file exists at the printed path (ls/cat it)
  2. Use an absolute path or fix the relative path relative to the working directory
  3. Check file read permissions
  4. Inspect the nested 'caused by' to distinguish file-not-found from JSON parse errors

Example fix

// before
KaratePom.load(Path.of("karate-pom.json"));
// after
Path cfg = Path.of("karate-pom.json");
if (!Files.exists(cfg)) throw new IllegalStateException("config missing: " + cfg.toAbsolutePath());
KaratePom.load(cfg);
Defensive patterns

Strategy: try-catch

Validate before calling

// Java: check readability before load
if (!Files.isReadable(configPath)) throw new IllegalStateException("unreadable config: " + configPath);
KaratePom.load(configPath);

Type guard

static boolean isReadableConfig(Path p) { return p != null && Files.isRegularFile(p) && Files.isReadable(p); }

Try / catch

try {
    KaratePom pom = KaratePom.load(configPath);
} catch (RuntimeException e) {
    throw new IllegalStateException("cannot load karate-pom at " + configPath + ": " + e.getCause(), e);
}

Prevention

When it happens

Trigger: Calling load() with a path to a missing, deleted, permission-blocked, or unreadable karate-pom.json, or a file that fails JSON parsing.

Common situations: Running from a working directory where the config path is relative and wrong; typo'd file name; config not committed to the repo so CI fails; unreadable permissions.

Understand the failure class

Background: "failed to read file", EACCES, ENOENT and "could not read <path>" errors: when a program can't read a file from disk — this error's family across 49 libraries.

Related errors


AI-assisted analysis of karatelabs/karate@a22eb90246 (2026-09-12). Data as JSON: /api/errors/b8832bb96c80aa5c. Report an issue: GitHub.

Appendix: source

Thrown at karate-core/src/main/java/io/karatelabs/core/KaratePom.java:183

     * @throws RuntimeException if file cannot be read or parsed
     */
    public static KaratePom load(String configPath) {
        return load(Path.of(configPath));
    }

    /**
     * Load configuration from a JSON file.
     *
     * @param configPath path to the JSON config file
     * @return parsed KaratePom
     * @throws RuntimeException if file cannot be read or parsed
     */
    public static KaratePom load(Path configPath) {
        try {
            String content = Files.readString(configPath);
            return parse(content);
        } catch (Exception e) {
            throw new RuntimeException("Failed to load config from: " + configPath, e);
        }
    }

    /**
     * Parse configuration from a JSON string.
     *
     * @param json JSON string
     * @return parsed KaratePom
     * @throws RuntimeException if JSON is invalid
     */
    public static KaratePom parse(String json) {
        Json j = Json.of(json);
        if (!j.isObject()) {
            throw new RuntimeException("Invalid config: expected JSON object");
        }
        KaratePom config = new KaratePom();

        // Parse paths

View on GitHub (pinned to a22eb90246)