{"record":{"id":"107ef5121aa362c7","repo":"ipfs/kubo","slug":"ipfs-not-initialized-please-run-ipfs-init","errorCode":null,"errorMessage":"ipfs not initialized, please run 'ipfs init'","messagePattern":"ipfs not initialized, please run 'ipfs init'","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"config/serialize/serialize.go","lineNumber":18,"sourceCode":"package fsrepo\n\nimport (\n\t\"encoding/json\"\n\t\"errors\"\n\t\"fmt\"\n\t\"io\"\n\t\"os\"\n\t\"path/filepath\"\n\n\t\"github.com/ipfs/kubo/config\"\n\n\t\"github.com/facebookgo/atomicfile\"\n)\n\n// ErrNotInitialized is returned when we fail to read the config because the\n// repo doesn't exist.\nvar ErrNotInitialized = errors.New(\"ipfs not initialized, please run 'ipfs init'\")\n\n// ReadConfigFile reads the config from `filename` into `cfg`.\nfunc ReadConfigFile(filename string, cfg any) error {\n\tf, err := os.Open(filename)\n\tif err != nil {\n\t\tif os.IsNotExist(err) {\n\t\t\terr = ErrNotInitialized\n\t\t}\n\t\treturn err\n\t}\n\tdefer f.Close()\n\tif err := json.NewDecoder(f).Decode(cfg); err != nil {\n\t\treturn fmt.Errorf(\"failure to decode config: %w\", err)\n\t}\n\treturn nil\n}\n\n// WriteConfigFile writes the config from `cfg` into `filename`.","sourceCodeStart":1,"sourceCodeEnd":36,"githubUrl":"https://github.com/ipfs/kubo/blob/329838acdfafae224582930457efe80aa217afc0/config/serialize/serialize.go#L1-L36","documentation":"ErrNotInitialized is the sentinel error returned by serialize.ReadConfigFile (and ReadUserResourceOverrides/openUserResourceOverrides) when the target config file does not exist (os.IsNotExist). It signals that the IPFS repo has not been initialized. Callers such as fsrepo detect it via errors.Is and either prompt initialization or treat missing resource-override files as optional.","triggerScenarios":"Running any command that needs the repo config (e.g. `ipfs config show`, daemon start, fsrepo.Open/Load) when IPFS_PATH/$IPFS_PATH/config does not exist; also reading libp2p-resource-limit-overrides.json when that file is absent (fsrepo.go maps it back to nil).","commonSituations":"Running `ipfs` before ever running `ipfs init`, pointing IPFS_PATH at a wrong/empty directory, running the daemon in a fresh container without an init step, or CI forgetting the init step.","solutions":["Run `ipfs init` to create the repo and its config file.","Verify IPFS_PATH points at the directory containing the existing repo (default ~/.ipfs).","If the repo was moved, restore the config file or re-init and copy settings over."],"exampleFix":"// before: running commands against uninitialized repo\nexport IPFS_PATH=/tmp/nonexistent\nipfs daemon // fails with ErrNotInitialized\n// after\nexport IPFS_PATH=/tmp/mynode\nipfs init\nipfs daemon","handlingStrategy":"try-catch","validationCode":"if _, err := os.Stat(filepath.Join(ipfsPath, \"config\")); os.IsNotExist(err) {\n    return fmt.Errorf(\"repo at %s not initialized; run 'ipfs init'\", ipfsPath)\n}","typeGuard":"func isNotInitialized(err error) bool { return errors.Is(err, serialize.ErrNotInitialized) }","tryCatchPattern":"if err := doThing(); err != nil {\n    if errors.Is(err, serialize.ErrNotInitialized) {\n        // run 'ipfs init' or surface an init prompt\n        return initRepo()\n    }\n    return err\n}","preventionTips":["Always run `ipfs init` before other commands in new environments/containers","Set IPFS_PATH explicitly and verify it contains a config file","Check errors with errors.Is(err, serialize.ErrNotInitialized), not string comparison"],"tags":["repo","initialization","go","config"],"backgroundTag":"repo-not-initialized","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"}