Custom modes fail to load with "ENAMETOOLONG: name too long" error #651

Closed
opened 2026-02-16 17:27:43 -05:00 by yindo · 3 comments
Owner

Originally created by @kavhnr on GitHub (Jul 11, 2025).

Bug Report

Summary

Custom modes defined in opencode.json configuration files fail to load, causing opencode to crash with an "ENAMETOOLONG: name too long" error during startup.

Environment

  • opencode version: 0.2.27
  • Platform: macOS (likely affects other platforms)
  • Configuration: Both global (~/.config/opencode/config.json) and project-specific (opencode.json)

Steps to Reproduce

  1. Create an opencode.json file in a project directory with a custom mode configuration following the official documentation example:
{
  "$schema": "https://opencode.ai/config.json",
  "mode": {
    "docs": {
      "prompt": "{file:./prompts/documentation.txt}",
      "tools": {
        "write": true,
        "edit": true,
        "bash": false,
        "read": true,
        "grep": true,
        "glob": true
      }
    }
  }
}
  1. Create the referenced prompt file at ./prompts/documentation.txt with any content
  2. Run opencode from the project directory

Expected Behavior

opencode should start successfully and allow switching to the custom "docs" mode using the Tab key or configured keybind.

Actual Behavior

opencode fails to start with the following error:

Error: Unexpected error, check log file at /Users/[user]/.local/share/opencode/log/[timestamp].log for more details

Log Output

The log file shows:

INFO  [timestamp] service=config $schema=https://opencode.ai/config.json mode=[object Object] loaded
INFO  [timestamp] service=provider init
INFO  [timestamp] service=provider providerID=anthropic found
INFO  [timestamp] service=default cmd=/Users/[user]/.cache/opencode/tui/tui-[hash]. tui
INFO  [timestamp] service=app name=mode registering service
INFO  [timestamp] service=app name=lsp shutdown
ERROR [timestamp] service=default name=Error message=ENAMETOOLONG: name too long, open fatal

Additional Context

  • The issue occurs with both the documentation example and other custom mode configurations
  • The same error occurs when adding custom modes to the global config file (~/.config/opencode/config.json)
  • Built-in modes ("build" and "plan") work correctly
  • The configuration validates successfully against the schema
  • The error suggests a filesystem operation is failing due to a path length limitation

Workaround

None found. Custom modes are currently unusable.

Documentation Reference

This appears to be a critical bug that prevents users from utilizing the custom modes feature as documented.

Originally created by @kavhnr on GitHub (Jul 11, 2025). ## Bug Report ### Summary Custom modes defined in `opencode.json` configuration files fail to load, causing opencode to crash with an "ENAMETOOLONG: name too long" error during startup. ### Environment - **opencode version**: 0.2.27 - **Platform**: macOS (likely affects other platforms) - **Configuration**: Both global (`~/.config/opencode/config.json`) and project-specific (`opencode.json`) ### Steps to Reproduce 1. Create an `opencode.json` file in a project directory with a custom mode configuration following the [official documentation example](https://opencode.ai/docs/modes/#custom-modes): ```json { "$schema": "https://opencode.ai/config.json", "mode": { "docs": { "prompt": "{file:./prompts/documentation.txt}", "tools": { "write": true, "edit": true, "bash": false, "read": true, "grep": true, "glob": true } } } } ``` 2. Create the referenced prompt file at `./prompts/documentation.txt` with any content 3. Run `opencode` from the project directory ### Expected Behavior opencode should start successfully and allow switching to the custom "docs" mode using the Tab key or configured keybind. ### Actual Behavior opencode fails to start with the following error: ``` Error: Unexpected error, check log file at /Users/[user]/.local/share/opencode/log/[timestamp].log for more details ``` ### Log Output The log file shows: ``` INFO [timestamp] service=config $schema=https://opencode.ai/config.json mode=[object Object] loaded INFO [timestamp] service=provider init INFO [timestamp] service=provider providerID=anthropic found INFO [timestamp] service=default cmd=/Users/[user]/.cache/opencode/tui/tui-[hash]. tui INFO [timestamp] service=app name=mode registering service INFO [timestamp] service=app name=lsp shutdown ERROR [timestamp] service=default name=Error message=ENAMETOOLONG: name too long, open fatal ``` ### Additional Context - The issue occurs with both the documentation example and other custom mode configurations - The same error occurs when adding custom modes to the global config file (`~/.config/opencode/config.json`) - Built-in modes ("build" and "plan") work correctly - The configuration validates successfully against the schema - The error suggests a filesystem operation is failing due to a path length limitation ### Workaround None found. Custom modes are currently unusable. ### Documentation Reference - [Custom modes documentation](https://opencode.ai/docs/modes/#custom-modes) - [Configuration schema](https://opencode.ai/config.json) - [Configuration documentation](https://opencode.ai/docs/config/#modes) This appears to be a critical bug that prevents users from utilizing the custom modes feature as documented.
yindo closed this issue 2026-02-16 17:27:43 -05:00
Author
Owner

@rob-balfre commented on GitHub (Jul 11, 2025):

Same here

@rob-balfre commented on GitHub (Jul 11, 2025): Same here
Author
Owner

@rob-balfre commented on GitHub (Jul 11, 2025):

https://github.com/sst/opencode/issues/861

@rob-balfre commented on GitHub (Jul 11, 2025): https://github.com/sst/opencode/issues/861
Author
Owner

@thdxr commented on GitHub (Jul 11, 2025):

this was fixed in v0.2.28

@thdxr commented on GitHub (Jul 11, 2025): this was fixed in [v0.2.28](https://github.com/sst/opencode/releases/tag/v0.2.28)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#651