kopia/kopia · error

error resolving config file path

Error message

error resolving config file path

What it means

Thrown by repo.Open when converting the provided config file path to an absolute path with filepath.Abs fails. This is a wrapper around a low-level OS/filesystem error and prevents the repository from being opened, since the configuration file location must be resolved before loading it.

Solutions

  1. Check the wrapped OS error; on Linux it is usually 'file name too long' or 'no such file or directory' for the CWD.
  2. Pass a shorter, absolute config path directly instead of relying on CWD resolution.
  3. Ensure the process's current working directory exists before calling Open.
  4. Set KOPIA_CONFIG_PATH to a valid absolute path and retry.

Example fix

// before: relative path from possibly-deleted CWD
rep, _ := repo.Open(ctx, "./config/repo.config", pass, opts)
// after: absolute path
abs, _ := filepath.Abs("./config/repo.config") // or hardcode /etc/kopia/repository.config
rep, _ := repo.Open(ctx, abs, pass, opts)
Defensive patterns

Strategy: validation

Validate before calling

if _, err := os.Stat(configFile); err != nil { return fmt.Errorf("config path unusable: %w", err) }
if len(configFile) > 4000 { return errors.New("config path too long") }

Type guard

func configPathOk(p string) bool { return filepath.IsAbs(p) && len(p) < 4000 }

Try / catch

rep, err := repo.Open(ctx, configFile, pass, opts)
if err != nil && strings.Contains(err.Error(), "error resolving config file path") {
    return fmt.Errorf("check KOPIA_CONFIG_PATH and current working directory: %w", err)
}

Prevention

When it happens

Trigger: Calling repo.Open (or CLI `kopia repository connect`) with a config-file path that cannot be resolved — e.g. extremely long paths exceeding OS limits, or paths with components that fail during working-directory resolution on a broken/deleted CWD.

Common situations: Running kopia from a deleted working directory; KOPIA_CONFIG_PATH pointing at a path beyond PATH_MAX; containers with odd mount setups where os.Getwd fails.

Understand the failure class

Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.

Related errors


AI-assisted analysis of kopia/kopia@82495e54b5 (2026-09-07). Data as JSON: /api/errors/5a003f0e32f9c146. Report an issue: GitHub.

Appendix: source

Thrown at repo/open.go:121

		if err != nil {
			log(ctx).Errorf("failed to open repository: %v", err)
		}
	}()

	if options == nil {
		options = &Options{}
	}

	if options.OnFatalError == nil {
		options.OnFatalError = func(err error) {
			log(ctx).Errorf("FATAL: %v", err)
			os.Exit(1)
		}
	}

	configFile, err = filepath.Abs(configFile)
	if err != nil {
		return nil, errors.Wrap(err, "error resolving config file path")
	}

	lc, err := LoadConfigFromFile(configFile)
	if err != nil {
		return nil, err
	}

	if lc.PermissiveCacheLoading && !lc.ReadOnly {
		return nil, ErrCannotWriteToRepoConnectionWithPermissiveCacheLoading
	}

	if lc.APIServer != nil {
		return openAPIServer(ctx, lc.APIServer, lc.ClientOptions, lc.Caching, password, options)
	}

	return openDirect(ctx, configFile, lc, password, options)
}

View on GitHub (pinned to 82495e54b5)