ipfs/kubo · error
%s is not writeable by the current user
Error message
%s is not writeable by the current user
What it means
Thrown by checkWritable when the IPFS_REPO_PATH (or target repo dir) exists but the current OS user cannot create files inside it: the probe file `<dir>/test` could not be created and the OS reported a permission error. Init aborts before creating any repo data. The message names the directory so you can inspect its ownership and mode.
Source
Thrown at cmd/ipfs/kubo/init.go:186
if !empty {
if err := addDefaultAssets(out, repoRoot); err != nil {
return err
}
}
return pinEmptyDir(repoRoot)
}
func checkWritable(dir string) error {
_, err := os.Stat(dir)
if err == nil {
// dir exists, make sure we can write to it
testfile := filepath.Join(dir, "test")
fi, err := os.Create(testfile)
if err != nil {
if os.IsPermission(err) {
return fmt.Errorf("%s is not writeable by the current user", dir)
}
return fmt.Errorf("unexpected error while checking writeablility of repo root: %s", err)
}
fi.Close()
return os.Remove(testfile)
}
if os.IsNotExist(err) {
// dir doesn't exist, check that we can create it
return os.Mkdir(dir, 0o775)
}
if os.IsPermission(err) {
return fmt.Errorf("cannot write to %s, incorrect permissions", err)
}
return err
}View on GitHub (pinned to 329838acdf)
Solutions
- Check ownership and permissions with `ls -ld <dir>` and fix them: `sudo chown -R $(id -u):$(id -g) <dir>` or `chmod u+w <dir>`.
- If the dir was created by a previous sudo run, remove it (`sudo rm -rf <dir>`) and re-run `ipfs init` as your normal user.
- Point IPFS_PATH at a directory you can write to, e.g. `export IPFS_PATH=$(mktemp -d)`.
- If the mount is read-only, remount read-write or choose a different location.
Example fix
// before sudo ipfs init # creates repo owned by root // after rm -rf ~/.ipfs # remove root-owned repo, then run as the regular user ipfs init
Defensive patterns
Strategy: validation
Validate before calling
dir := os.Getenv("IPFS_PATH")
if dir == "" {
dir = "~/.ipfs"
}
fi, err := os.Stat(dir)
if err == nil && fi.IsDir() {
probe, perr := os.Create(filepath.Join(dir, ".write-test"))
if perr != nil {
log.Fatalf("repo dir %s not writable: %v", dir, perr)
}
probe.Close()
os.Remove(filepath.Join(dir, ".write-test"))
} Prevention
- Never run `ipfs init` with sudo; fix permissions instead
- After switching users or containers, `chown -R` the repo to the running user
- Set IPFS_PATH explicitly in scripts to a path you control
When it happens
Trigger: Calling `ipfs init` with IPFS_PATH or the default ~/.ipfs pointing at an existing directory where os.Create("<dir>/test") fails with EACCES/EPERM (e.g. dir owned by root or another user, or read-only mount).
Common situations: Running ipfs under systemd/Docker as a user different from the repo owner; IPFS_PATH pointing into /root from an unprivileged shell; a volume mounted read-only; a previous run with sudo created ~/.ipfs owned by root.
Related errors
- cannot write to %s, incorrect permissions
- serveHTTPApi: SetAPIAddr() failed: %w
- unexpected error while checking writeablility of repo root:
- init: seeding init docs failed: %s
- creating temporary file for %s: %w
AI-assisted analysis of ipfs/kubo@329838acdf (2026-09-03).
Data as JSON: /api/errors/46bf3c4e4c854f14.
Report an issue: GitHub.