Skip to content

os: Root's MkdirAll can't create paths ending in forward slashes #80308

Description

@taylorsilva

Go version

1.26.5 and 1.25.12

Output of go env in your module/workspace:

N/A

What did you do?

Using root.MkdirAll to create a path, with the given path ending in a / results in the following error:

mkdirat some/path/: no such file or directory

main.go to reproduce:

package main

import (
	"log"
	"os"
)

func main() {
	r, err := os.OpenRoot(".")
	if err != nil {
		log.Fatalf("OpenRoot: %s", err.Error())
	}

	err = r.MkdirAll("some/path/", 0755)
	if err != nil {
		log.Fatalf("MkdirAll: %s", err.Error())
	}
}

Running the above program with 1.26.5 or 1.25.12 results in the error:

GOTOOLCHAIN=go1.26.5 go run main.go
GOTOOLCHAIN=go1.25.12 go run main.go

Using prior patch versions works as expected.

Changing some/path/ to some/path is a workaround.

What did you see happen?

This error occurs:

mkdirat some/path/: no such file or directory

What did you expect to see?

No error and the entire path is created.

Metadata

Metadata

Assignees

Labels

FixPendingIssues that have a fix which has not yet been reviewed or submitted.release-blocker

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions