hashicorp/nomad · error
Error loading %s: %s
Error message
Error loading %s: %s
What it means
LoadConfig(path) dispatches to LoadConfigDir for directories or ParseConfigFile for single files. When parsing a single config file fails, the error is wrapped as 'Error loading <path>: <reason>'. The wrapped message carries the actual parse/validation failure from ParseConfigFile (e.g. HCL/JSON syntax errors).
Source
Thrown at command/agent/config.go:3271
}
// LoadConfig loads the configuration at the given path, regardless if its a file or
// directory. Called for each -config to build up the runtime config value. Do not apply any
// default values, defaults should be added once in DefaultConfig
func LoadConfig(path string) (*Config, error) {
fi, err := os.Stat(path)
if err != nil {
return nil, err
}
if fi.IsDir() {
return LoadConfigDir(path)
}
cleaned := filepath.Clean(path)
config, err := ParseConfigFile(cleaned)
if err != nil {
return nil, fmt.Errorf("Error loading %s: %s", cleaned, err)
}
config.Files = append(config.Files, cleaned)
return config, nil
}
// LoadConfigDir loads all the configurations in the given directory
// in alphabetical order.
func LoadConfigDir(dir string) (*Config, error) {
f, err := os.Open(dir)
if err != nil {
return nil, err
}
defer f.Close()
fi, err := f.Stat()
if err != nil {
return nil, errView on GitHub (pinned to 482b49bf1a)
Solutions
- Read the wrapped underlying error after the colon — it names the exact parse problem and line
- Validate the file with hclfmt or a JSON linter
- Convert JSON configs to HCL carefully; they are not interchangeable syntactically
- Confirm the path is the intended file and is readable
Example fix
// before (config.json)
{"datacenter": "dc1",,}
// after
{"datacenter": "dc1"} Defensive patterns
Strategy: try-catch
Validate before calling
if fi, err := os.Stat(path); err == nil && !fi.IsDir() {
if err := validateConfigFile(path); err != nil {
return fmt.Errorf("config file %s invalid before load: %w", path, err)
}
} Try / catch
config, err := agentcfg.LoadConfig(path)
if err != nil {
var perr *os.PathError
if errors.As(err, &perr) { return perr }
return fmt.Errorf("load %s: %w", path, err)
} Prevention
- Run consul validate on all config files in CI
- Keep JSON and HCL files syntactically separate
- Format configs with hclfmt / jq before deploy
- Make one config change per deploy to isolate breakage
When it happens
Trigger: consul agent -config-file=<path> where path is a file whose contents fail ParseConfigFile — invalid HCL/JSON syntax, unknown keys, wrong types, or unreadable content.
Common situations: Typos in JSON/HCL config files, mixing JSON syntax into .hcl files, trailing commas in JSON, or passing a file that contains config from another tool.
Related errors
- configuration path must be a directory: %s
- failed to decode HCL file %s: %w
- failed to parse HCL file %s: %w
- only one storage block is allowed
- failed to parse config:
AI-assisted analysis of hashicorp/nomad@482b49bf1a (2026-09-04).
Data as JSON: /api/errors/f979d86bde8517d1.
Report an issue: GitHub.