ipfs/kubo · error

failed to access file: %w

Error message

failed to access file: %w

What it means

Failure in `ipfs multibase encode` while obtaining the input stream: cmdenv.GetFileArg could not open or access the file argument (or stdin), e.g. missing argument, unreadable path, or an empty input set. Wraps the underlying access error; no bytes were read yet.

Source

Thrown at core/commands/multibase.go:67

	Arguments: []cmds.Argument{
		cmds.FileArg("file", true, false, "data to encode").EnableStdin(),
	},
	Options: []cmds.Option{
		cmds.StringOption(mbaseOptionName, "multibase encoding").WithDefault("base64url"),
	},
	Run: func(req *cmds.Request, resp cmds.ResponseEmitter, env cmds.Environment) error {
		if err := req.ParseBodyArgs(); err != nil {
			return err
		}
		encoderName, _ := req.Options[mbaseOptionName].(string)
		encoder, err := mbase.EncoderByName(encoderName)
		if err != nil {
			return err
		}
		files := req.Files.Entries()
		file, err := cmdenv.GetFileArg(files)
		if err != nil {
			return fmt.Errorf("failed to access file: %w", err)
		}
		buf, err := io.ReadAll(file)
		if err != nil {
			return fmt.Errorf("failed to read file contents: %w", err)
		}
		encoded := encoder.Encode(buf)
		reader := strings.NewReader(encoded)
		return resp.Emit(reader)
	},
}

var mbaseDecodeCmd = &cmds.Command{
	Helptext: cmds.HelpText{
		Tagline: "Decode multibase string",
		LongDescription: `
This command expects multibase inside of a file or via stdin:

  > echo -n hello | ipfs multibase encode -b base16 > file

View on GitHub (pinned to 329838acdf)

Solutions

  1. Pass the data explicitly: ipfs multibase encode <file> or pipe via stdin
  2. Check the file exists and is readable
  3. Fix argument quoting so the shell delivers the path correctly
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at core/commands/multibase.go:67 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/45de685869fbccb9. Report an issue: GitHub.