Skip to content

Opencode hangs at startup if a .git repo is present and inotify user instances run out #16610

Description

@Christoph-D

Description

Steps to reproduce

  1. Run sudo sysctl -w fs.inotify.max_user_instances=16 or some other lower number
  2. Run opencode in a path that contains a .git directory.

Expected behavior

Opencode starts normally. Or, if it really can't work without a lot of inotify instances, then it should show a clear error message and exit.

Actual behavior

Opencode hangs at startup with a blank screen, completely unresponsive.

Likely root cause

Opencode doesn't handle the error "EMFILE (Too many open files)" when creating new inotify instances.

Workaround

Increase the systemwide limit of inotify user instances: sudo sysctl -w fs.inotify.max_user_instances=2048

Log

Last log lines from where it hangs:

$ opencode run hello --print-logs
[...]
INFO  2026-03-08T15:39:44 +2ms service=server method=GET path=/event request
INFO  2026-03-08T15:39:44 +0ms service=server status=started method=GET path=/event request
INFO  2026-03-08T15:39:44 +0ms service=server method=POST path=/session/ses_331e54564ffeUxW4QHflpXACOJ/message request
INFO  2026-03-08T15:39:44 +0ms service=server status=started method=POST path=/session/ses_331e54564ffeUxW4QHflpXACOJ/message request
INFO  2026-03-08T15:39:44 +0ms service=server event connected
INFO  2026-03-08T15:39:44 +1ms service=bus type=* subscribing
INFO  2026-03-08T15:39:44 +5ms service=server status=completed duration=6 method=GET path=/event request
INFO  2026-03-08T15:39:44 +1ms service=server status=completed duration=7 method=POST path=/session/ses_331e54564ffeUxW4QHflpXACOJ/message request
INFO  2026-03-08T15:39:44 +3ms service=vcs branch=HEAD initialized
INFO  2026-03-08T15:39:44 +0ms service=bus type=file.watcher.updated subscribing
^C

Plugins

None. The same issue happens when I disable all plugins.

OpenCode version

1.2.21

Steps to reproduce

  1. Run sudo sysctl -w fs.inotify.max_user_instances=16 or some other lower number
  2. Run opencode in a path that contains a .git directory.

Screenshot and/or share link

No response

Operating System

Ubuntu 24.04, Alpine 3.23

Terminal

bash

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions