You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Skill discovery crashes with ENAMETOOLONG on symlink cycles #45961
When a skill discovery directory (e.g. ~/.agents/skills) resolves to a path inside a source skill collection, ln -s creates a self-referential symlink. OpenCode's skill scanner follows it recursively and crashes with ENAMETOOLONG.
This happens because scan() in packages/opencode/src/skill/index.ts passes symlink: true to glob (which maps to follow: true), and there is no cycle detection or depth limit.
Reproduction
# clone a skills repo
git clone [email protected]:example/skills.git &&cd skills
# make the discovery dir point into the source collection
ln -s "$PWD/skills"~/.agents/skills
# create a skill link -- ln follows the directory symlink and# creates skills/foo/foo pointing at itself
ln -s "$PWD/skills/foo"~/.agents/skills/foo
# start opencode -- glob follows the cycle until ENAMETOOLONG
opencode
Suggested fix
Any of these would work (in order of simplicity):
Add maxDepth to the glob call. Skill bundles are shallow (skills/<name>/SKILL.md), so a depth of 3-4 prevents infinite traversal without changing behavior.
Catch ENAMETOOLONG and ELOOP in the scan function and skip the path with a warning.
Track visited realpaths before descending into each directory.
Activity
github-actions commentedon Aug 28, 2026
This issue might be a duplicate of existing issues. Please check:
Please review those issues and consider adding your reproduction details or suggested fix there if they cover the same problem.