ipfs/kubo · error

opening repo (is the daemon running?): %w

Error message

opening repo (is the daemon running?): %w

What it means

`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.

Source

Thrown at core/commands/files.go:1760

		if len(req.Arguments) > 0 {
			var err error
			newRootCid, err = cmdutils.CidFromArg(req.Arguments[0])
			if err != nil {
				return fmt.Errorf("invalid CID %q: %w", req.Arguments[0], err)
			}
		} else {
			// Default to empty directory
			newRootCid = ft.EmptyDirNode().Cid()
		}

		// Get config root to open repo directly
		cctx := env.(*oldcmds.Context)
		cfgRoot := cctx.ConfigRoot

		// Open repo directly (daemon must not be running)
		repo, err := fsrepo.Open(cfgRoot)
		if err != nil {
			return fmt.Errorf("opening repo (is the daemon running?): %w", err)
		}
		defer repo.Close()

		localDS := repo.Datastore()
		bs := bstore.NewBlockstore(localDS)

		// Check new root exists locally and is a directory
		hasBlock, err := bs.Has(req.Context, newRootCid)
		if err != nil {
			return fmt.Errorf("checking if new root exists: %w", err)
		}
		if !hasBlock {
			// Special case: empty dir is always available (hardcoded in boxo)
			emptyDirCid := ft.EmptyDirNode().Cid()
			if !newRootCid.Equals(emptyDirCid) {
				return fmt.Errorf("new root %s does not exist locally; fetch it first with 'ipfs block get'", enc.Encode(newRootCid))
			}
		}

View on GitHub (pinned to 329838acdf)

Solutions

  1. Stop the daemon (`ipfs shutdown` or kill it) before running `ipfs files chroot`, then restart it afterward.
  2. Verify IPFS_PATH points to an initialized repo (`ipfs --path <dir> repo stat`); run `ipfs init` if needed.
  3. Check repo directory permissions if Open still fails after stopping the daemon.

Example fix

// before
ipfs daemon &
ipfs files chroot --confirm <cid>   # opening repo (is the daemon running?)
// after
ipfs shutdown
ipfs files chroot --confirm <cid>
ipfs daemon &
Defensive patterns

Strategy: retry

Validate before calling

pgrep -f 'ipfs daemon' && echo 'stop the daemon first'; [ -f "$IPFS_PATH/config" ] || echo 'repo not initialized'

Try / catch

if err := chrootRun(); err != nil && strings.Contains(err.Error(), "opening repo") {
    // stop daemon, then retry
    stopDaemon(); err = chrootRun()
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of ipfs/kubo@329838acdf (2026-09-03). Data as JSON: /api/errors/b388f9e864f8fc9b. Report an issue: GitHub.