{"record":{"id":"ab918f91bbd9b31a","repo":"ipfs/kubo","slug":"failed-to-get-repo-path-w","errorCode":null,"errorMessage":"failed to get repo path: %w","messagePattern":"failed to get repo path: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"config/autoconf_client.go","lineNumber":37,"sourceCode":"\tclientCache *autoconf.Client\n\tclientErr   error\n)\n\n// GetAutoConfClient returns a cached autoconf client or creates a new one.\n// This is thread-safe and uses a singleton pattern.\nfunc GetAutoConfClient(cfg *Config) (*autoconf.Client, error) {\n\tclientOnce.Do(func() {\n\t\tclientCache, clientErr = newAutoConfClient(cfg)\n\t})\n\treturn clientCache, clientErr\n}\n\n// newAutoConfClient creates a new autoconf client with the given config\nfunc newAutoConfClient(cfg *Config) (*autoconf.Client, error) {\n\t// Get repo path for cache directory\n\trepoPath, err := PathRoot()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to get repo path: %w\", err)\n\t}\n\n\t// Prepare refresh interval with nil check\n\trefreshInterval := cfg.AutoConf.RefreshInterval\n\tif refreshInterval == nil {\n\t\trefreshInterval = &OptionalDuration{}\n\t}\n\n\t// Use default URL if not specified\n\turl := cfg.AutoConf.URL.WithDefault(DefaultAutoConfURL)\n\n\t// Build client options\n\toptions := []autoconf.Option{\n\t\tautoconf.WithCacheDir(filepath.Join(repoPath, \"autoconf\")),\n\t\tautoconf.WithUserAgent(version.GetUserAgentVersion()),\n\t\tautoconf.WithCacheSize(DefaultAutoConfCacheSize),\n\t\tautoconf.WithTimeout(DefaultAutoConfTimeout),\n\t\tautoconf.WithRefreshInterval(refreshInterval.WithDefault(DefaultAutoConfRefreshInterval)),","sourceCodeStart":19,"sourceCodeEnd":55,"githubUrl":"https://github.com/ipfs/kubo/blob/329838acdfafae224582930457efe80aa217afc0/config/autoconf_client.go#L19-L55","documentation":"newAutoConfClient needs the repo path to build the AutoConf cache directory and calls config.PathRoot() to get it. If PathRoot fails (it resolves IPFS_PATH / the repo root), the error is wrapped as 'failed to get repo path: %w'. The underlying error is what matters — typically the repo path could not be determined from the environment or flags.","triggerScenarios":"Daemon startup (or any path constructing the AutoConf client with AutoConf.Enabled) when config.PathRoot() returns an error, e.g. IPFS_PATH points somewhere unusable or the repo root cannot be resolved.","commonSituations":"IPFS_PATH set to an invalid/unreadable path; running in a sandboxed environment where the home directory or env vars are missing; corrupted environment when launching the daemon programmatically.","solutions":["Inspect the wrapped '%w' cause with errors.Unwrap to see why PathRoot failed","Set/fix the IPFS_PATH environment variable to a writable directory","Initialize the repo (ipfs init) at the configured path before starting the daemon","Pass an explicit --repo-dir flag if invoking the binary directly"],"exampleFix":"// before\nIPFS_PATH=/nonexistent/root ipfs daemon\n// after\nexport IPFS_PATH=~/.ipfs\nipfs init   # if not already initialized\nipfs daemon","handlingStrategy":"try-catch","validationCode":"if os.Getenv(\"IPFS_PATH\") == \"\" && !repoInitialized() { initRepo() }","typeGuard":null,"tryCatchPattern":"if _, err := PathRoot(); err != nil { return fmt.Errorf(\"autoconf disabled: repo path unavailable: %w\", err) }\nclient, err := newAutoConfClient(cfg)\nif err != nil { var pe *PathError; if errors.As(err, &pe) { log.Warn(\"bad IPFS_PATH, skipping autoconf\") } else { return err } }","preventionTips":["Always set a valid, writable IPFS_PATH before starting the daemon","Run ipfs init before enabling AutoConf-dependent features","Log errors.Unwrap(err) to surface the root cause of path resolution failures"],"tags":["config","autoconf","repo-path","startup"],"backgroundTag":"repo-path-resolution-failed","analyzedSha":"329838acdfafae224582930457efe80aa217afc0","analyzedAt":"2026-09-03T18:30:52.135Z","contentChangedAt":"2026-09-03T18:30:52.135Z","schemaVersion":2},"datasetVersion":"2026-09-11T00:17:11.886Z"}