{"record":{"id":"b388f9e864f8fc9b","repo":"ipfs/kubo","slug":"opening-repo-is-the-daemon-running-w","errorCode":null,"errorMessage":"opening repo (is the daemon running?): %w","messagePattern":"opening repo \\(is the daemon running\\?\\): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/commands/files.go","lineNumber":1760,"sourceCode":"\t\tif len(req.Arguments) > 0 {\n\t\t\tvar err error\n\t\t\tnewRootCid, err = cmdutils.CidFromArg(req.Arguments[0])\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"invalid CID %q: %w\", req.Arguments[0], err)\n\t\t\t}\n\t\t} else {\n\t\t\t// Default to empty directory\n\t\t\tnewRootCid = ft.EmptyDirNode().Cid()\n\t\t}\n\n\t\t// Get config root to open repo directly\n\t\tcctx := env.(*oldcmds.Context)\n\t\tcfgRoot := cctx.ConfigRoot\n\n\t\t// Open repo directly (daemon must not be running)\n\t\trepo, err := fsrepo.Open(cfgRoot)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"opening repo (is the daemon running?): %w\", err)\n\t\t}\n\t\tdefer repo.Close()\n\n\t\tlocalDS := repo.Datastore()\n\t\tbs := bstore.NewBlockstore(localDS)\n\n\t\t// Check new root exists locally and is a directory\n\t\thasBlock, err := bs.Has(req.Context, newRootCid)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"checking if new root exists: %w\", err)\n\t\t}\n\t\tif !hasBlock {\n\t\t\t// Special case: empty dir is always available (hardcoded in boxo)\n\t\t\temptyDirCid := ft.EmptyDirNode().Cid()\n\t\t\tif !newRootCid.Equals(emptyDirCid) {\n\t\t\t\treturn fmt.Errorf(\"new root %s does not exist locally; fetch it first with 'ipfs block get'\", enc.Encode(newRootCid))\n\t\t\t}\n\t\t}","sourceCodeStart":1742,"sourceCodeEnd":1778,"githubUrl":"https://github.com/ipfs/kubo/blob/329838acdfafae224582930457efe80aa217afc0/core/commands/files.go#L1742-L1778","documentation":"`ipfs files chroot` is a local-only, NoRemote command that opens the repo directly with fsrepo.Open(cfgRoot). fsrepo.Open fails if the repository is locked (a daemon is already running against it) or the repo path is missing/uninitialized, and the command wraps that failure with this message.","triggerScenarios":"Running `ipfs files chroot` while `ipfs daemon` is running on the same IPFS_PATH (repo lock held); running against an uninitialized repo directory; IPFS_PATH pointing at the wrong/nonexistent location.","commonSituations":"Users with a long-running daemon attempting local file maintenance; CI scripts that start a daemon and then run chroot in the same env; misconfigured IPFS_PATH or permission issues on the repo directory.","solutions":["Stop the daemon (`ipfs shutdown` or kill it) before running `ipfs files chroot`, then restart it afterward.","Verify IPFS_PATH points to an initialized repo (`ipfs --path <dir> repo stat`); run `ipfs init` if needed.","Check repo directory permissions if Open still fails after stopping the daemon."],"exampleFix":"// before\nipfs daemon &\nipfs files chroot --confirm <cid>   # opening repo (is the daemon running?)\n// after\nipfs shutdown\nipfs files chroot --confirm <cid>\nipfs daemon &","handlingStrategy":"retry","validationCode":"pgrep -f 'ipfs daemon' && echo 'stop the daemon first'; [ -f \"$IPFS_PATH/config\" ] || echo 'repo not initialized'","typeGuard":null,"tryCatchPattern":"if err := chrootRun(); err != nil && strings.Contains(err.Error(), \"opening repo\") {\n    // stop daemon, then retry\n    stopDaemon(); err = chrootRun()\n}","preventionTips":["Never run NoRemote commands like `files chroot` while a daemon holds IPFS_PATH","Use a dedicated IPFS_PATH for maintenance tasks if a daemon must stay up","Check `ipfs repo stat` succeeds before local repo surgery"],"tags":["repo","fsrepo","daemon","lock","cli"],"backgroundTag":"repo-lock-held-by-daemon","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"}