hashicorp/nomad · error

Error loading configuration from %s: %s

Error message

Error loading configuration from %s: %s

What it means

This error is produced by the `config validate` command when agent.LoadConfig(path) fails to read or parse a configuration file. The command wraps the underlying load error with the file path and appends it to a multierror so all failing paths are reported at once. It indicates the HCP/Consul agent configuration at the given path could not be loaded (missing file, bad permissions, or invalid syntax).

Source

Thrown at command/config_validate.go:69

	flags := c.Meta.FlagSet(c.Name(), FlagSetClient)
	flags.Usage = func() { c.Ui.Output(c.Help()) }
	if err := flags.Parse(args); err != nil {
		c.Ui.Error(err.Error())
		return 1
	}

	configPath := flags.Args()
	if len(configPath) < 1 {
		c.Ui.Error("Must specify at least one config file or directory")
		return 1
	}

	config := agent.DefaultConfig()

	for _, path := range configPath {
		fc, err := agent.LoadConfig(path)
		if err != nil {
			multierror.Append(&mErr, fmt.Errorf(
				"Error loading configuration from %s: %s", path, err))
			continue
		}
		if fc == nil || reflect.DeepEqual(fc, &agent.Config{}) {
			c.Ui.Warn(fmt.Sprintf("No configuration loaded from %s", path))
		}

		config = config.Merge(fc)
	}
	if err := mErr.ErrorOrNil(); err != nil {
		c.Ui.Error(err.Error())
		return 1
	}
	cmd := agent.Command{Ui: c.Ui}
	valid := cmd.IsValidConfig(config, agent.DefaultConfig())
	if !valid {
		c.Ui.Error("Configuration is invalid")
		return 1

View on GitHub (pinned to 482b49bf1a)

Solutions

  1. Verify the path passed to config validate exists and is readable (ls/stat the file or directory).
  2. Fix HCL/JSON syntax errors in the config file — the wrapped err names the exact line/parse problem.
  3. If using a config directory, ensure it contains .hcl or .json files the loader recognizes.
  4. Run as a user with permission to read the config file, or adjust file permissions.
  5. Create a minimal valid config file if you only intend to smoke-test validation.

Example fix

// before
consul validate ./conifg/
// after
consul validate ./config/
Defensive patterns

Strategy: validation

Validate before calling

info, err := os.Stat(path)
if err != nil { return fmt.Errorf("config path %s not accessible: %w", path, err) }
_ = info

Type guard

null

Try / catch

// LoadConfig returns (nil, err); handle before use
fc, err := agent.LoadConfig(path)
if err != nil {
    return fmt.Errorf("config %s invalid: %w", path, err)
}
if fc == nil {
    // treat as no config loaded
}

Prevention

When it happens

Trigger: Running the config validate command (command/config_validate.go Run) with one or more -config-file/-config-dir paths where agent.LoadConfig returns an error: nonexistent path, unreadable file, invalid HCL/JSON syntax, or a directory that yields no parseable config.

Common situations: Typo in the config file path; running the command from a directory with no config files; config file with HCL syntax errors; a config dir containing only unsupported files; insufficient file permissions; passing an empty directory (also triggers a separate 'No configuration loaded' warning).

Related errors


AI-assisted analysis of hashicorp/nomad@482b49bf1a (2026-09-04). Data as JSON: /api/errors/9dbebee253a4d9d6. Report an issue: GitHub.