ipfs/kubo · error

expected a regular file

Error message

expected a regular file

What it means

The init command received a file entry, but files.FileFromEntry returned nil, i.e. the entry was not a regular byte file (a directory or symlink entry). The custom config must be a single readable JSON file.

Source

Thrown at cmd/ipfs/kubo/init.go:94

		cctx := env.(*oldcmds.Context)
		empty, _ := req.Options[emptyRepoOptionName].(bool)
		algorithm, _ := req.Options[algorithmOptionName].(string)
		nBitsForKeypair, nBitsGiven := req.Options[bitsOptionName].(int)

		var conf *config.Config

		f := req.Files
		if f != nil {
			it := req.Files.Entries()
			if !it.Next() {
				if it.Err() != nil {
					return it.Err()
				}
				return errors.New("file argument was nil")
			}
			file := files.FileFromEntry(it)
			if file == nil {
				return errors.New("expected a regular file")
			}

			conf = &config.Config{}
			if err := json.NewDecoder(file).Decode(conf); err != nil {
				return err
			}
		}

		if conf == nil {
			var err error
			var identity config.Identity
			if nBitsGiven {
				identity, err = config.CreateIdentity(os.Stdout, []options.KeyGenerateOption{
					options.Key.Size(nBitsForKeypair),
					options.Key.Type(algorithm),
				})
			} else {
				identity, err = config.CreateIdentity(os.Stdout, []options.KeyGenerateOption{

View on GitHub (pinned to 329838acdf)

Solutions

  1. Supply a regular file containing the JSON configuration, not a directory
  2. Flatten symlinked inputs to the actual file before passing it
Defensive patterns

Strategy: type-guard

When it happens

Trigger: Thrown at cmd/ipfs/kubo/init.go:94 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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