(*os.File).Chmod fails on the js/wasm target with "No such file or directory" even though the file was just created by os.CreateTemp and the handle is still open. The path-based os.Chmod counterpart fails identically.
Reproduction:
package main
import (
"fmt"
"log"
"os"
)
func main() {
f, err := os.CreateTemp("", "chmod-demo-*")
if err != nil {
log.Fatal(err)
}
tmpName := f.Name()
defer os.Remove(tmpName)
defer f.Close()
fmt.Println("=== os.File.Chmod (changes via open *os.File) ===")
before, _ := f.Stat()
fmt.Printf("before: %#o\n", before.Mode().Perm())
if err := f.Chmod(os.ModePerm); err != nil {
log.Fatal(err)
}
after, _ := f.Stat()
fmt.Printf("after (0777): %#o\n", after.Mode().Perm())
fmt.Println("\n=== os.Chmod (changes via path) ===")
before2, _ := os.Stat(tmpName)
fmt.Printf("before: %#o\n", before2.Mode().Perm())
if err := os.Chmod(tmpName, 0644); err != nil {
log.Fatal(err)
}
after2, _ := os.Stat(tmpName)
fmt.Printf("after (0644): %#o\n", after2.Mode().Perm())
}
Actual output (go1.20.3 js/wasm, Hackpad playground):
$ ./playground
2026/05/22 21:58:41 chmod /tmp/chmod-demo-1043981024: No such file or directory
=== os.File.Chmod (changes via open *os.File) ===
before: 0600
exit status 1
Expected output (any non-wasm target):
$ ./playground
=== os.File.Chmod (changes via open *os.File) ===
before: 0600
after (0777): 0777
=== os.Chmod (changes via path) ===
before: 0777
after (0644): 0644
(*os.File).Chmodfails on thejs/wasmtarget with "No such file or directory" even though the file was just created byos.CreateTempand the handle is still open. The path-basedos.Chmodcounterpart fails identically.Reproduction:
Actual output (
go1.20.3 js/wasm, Hackpad playground):Expected output (any non-wasm target):