slimtoolkit/slim · error

cannot create execution - touch event file %q failed: %w

Error message

cannot create execution - touch event file %q failed: %w

What it means

NewStandalone builds a standalone execution that streams events to an event file and reads its start command from a command file. Before anything else it calls fsutil.Touch(eventFileName) which creates the event file and any missing parent directories. If that touch fails (unwritable path, permission denied, invalid path, read-only filesystem), the execution cannot be created and this wrapped error is returned.

Source

Thrown at pkg/app/sensor/execution/standalone.go:36

	"github.com/slimtoolkit/slim/pkg/util/fsutil"
)

type standaloneExe struct {
	hookExecutor

	commandCh chan command.Message
	eventFile io.WriteCloser
}

func NewStandalone(
	ctx context.Context,
	commandFileName string,
	eventFileName string,
	lifecycleHookCommand string,
) (Interface, error) {
	// fsutil.Touch() creates (potentially missing) folder(s).
	if err := fsutil.Touch(eventFileName); err != nil {
		return nil, fmt.Errorf(
			"cannot create execution - touch event file %q failed: %w",
			eventFileName, err,
		)
	}

	eventFile, err := os.OpenFile(eventFileName, os.O_APPEND|os.O_WRONLY|os.O_SYNC, 0644)
	if err != nil {
		return nil, fmt.Errorf(
			"cannot create execution - open event file %q failed: %w",
			eventFileName, err,
		)
	}

	cmd, err := readCommandFile(commandFileName)
	if err != nil {
		return nil, fmt.Errorf(
			"cannot create execution - cannot read command file %q: %w",
			commandFileName, err,

View on GitHub (pinned to 81940d17fa)

Solutions

  1. Check the wrapped error (%w) to see the underlying fs failure and fix the root cause (permissions, missing mount, bad path).
  2. Ensure the parent directory of eventFileName exists and is writable by the sensor process user (chown/chmod or mount a writable volume).
  3. Verify the filesystem is not read-only (e.g. container rootfs mounted ro) and point the event file to a writable path.

Example fix

// before
iface, err := execution.NewStandalone("/cmd", "/nonexistent/events.sock", hook)
// after
os.MkdirAll("/var/run/sensor", 0755) // ensure writable dir
iface, err := execution.NewStandalone("/cmd", "/var/run/sensor/events.sock", hook)
Defensive patterns

Strategy: validation

Validate before calling

func canCreate(path string) error {
    dir := filepath.Dir(path)
    if fi, err := os.Stat(dir); err != nil {
        return err
    } else if !fi.IsDir() {
        return fmt.Errorf("%s is not a directory", dir)
    }
    f, err := os.OpenFile(path, os.O_CREATE|os.O_WRONLY, 0644)
    if err != nil { return err }
    return f.Close()
}

Type guard

func isPathWritableError(err error) bool {
    return errors.Is(err, os.ErrPermission) || errors.Is(err, syscall.EROFS) || errors.Is(err, syscall.ENOENT)
}

Try / catch

exec, err := execution.NewStandalone(cmdFile, eventFile, hook)
if err != nil && strings.Contains(err.Error(), "touch event file") {
    log.Fatalf("event file path unusable: %v", err) // fix perms/mount before retry
}

Prevention

When it happens

Trigger: Calling NewStandalone (via newExecution) with an eventFileName whose parent directory cannot be created or written: missing permissions, read-only mount, invalid characters in path, or disk errors.

Common situations: Container running as non-root user without write access to the mount path; event file directory not mounted/volume not provisioned; SELinux/AppArmor blocking file creation; typo in the configured events path.

Related errors


AI-assisted analysis of slimtoolkit/slim@81940d17fa (2026-08-31). Data as JSON: /api/errors/761827048b26a429. Report an issue: GitHub.