Skip to content

Bug Report: Opencode Server Fails with ENOENT posix_spawn '/usr/bin/rg' When Directory Parameter is Provided #3158

Closed

Description

@wojons

Bug Report: Opencode Server Fails with ENOENT posix_spawn '/usr/bin/rg' When Directory Parameter is Provided

Issue Description

When sending a message to an opencode session with a directory query parameter, the server attempts to spawn ripgrep (rg) but fails with ENOENT because rg is not available in the server's runtime environment (Docker container).

Without the directory parameter, the request succeeds.

Steps to Reproduce

  1. Start opencode server (running in Docker container).
  2. Create a session: curl -X POST "http://localhost:42423/session?directory=/path/to/dir" -H "Content-Type: application/json" -H "X-API-KEY: your_api_key" -d '{"title":"Test Session"}'
  3. Send a message with directory: curl -v -X POST "http://localhost:42423/session/{session_id}/message?directory=/path/to/dir" -H "Content-Type: application/json" -H "X-API-KEY: your_api_key" -d '{"parts":[{"type":"text","text":"Test message"}]}'

Expected Behavior

Message should be processed successfully, as it does without the directory parameter.

Actual Behavior

HTTP 400 Bad Request with error: {"name":"UnknownError","data":{"message":"Error: ENOENT: no such file or directory, posix_spawn '/usr/bin/rg'"}}

Failing Curl Command and Output

Command:

curl -v -X POST "http://localhost:42423/session/ses_61fb303adffepX31IYrwrNVLBu/message?directory=%2Fconfig%2Fworkspace%2Fwhatsapp-mcp%2Fwhatsapp-bridge%2Fstore%2Fsessions%2F14248351223-s.whatsapp.net-c8a203c244cfad1c" -H "Content-Type: application/json" -H "X-API-KEY: your_opencode_api_key_here" -d '{"parts":[{"type":"text","text":"You are a helpful AI assistant integrated with WhatsApp.\n\n[START BATCH]\n- Message ID: AC93D0E4BC3075B43E6845B07AC1AB58\n- Chat JID: [email protected]\n- Sender: 14248351223\n- Timestamp: 2025-10-14 03:19:25\n\nHhjjj"}]}'

Output:

* Host localhost:42423 was resolved.
* IPv6: ::1
* IPv4: 127.0.0.1
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed

  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0*   Trying [::1]:42423...
* connect to ::1 port 42423 from ::1 port 34442 failed: Connection refused
*   Trying 127.0.0.1:42423...
* Connected to localhost (127.0.0.1) port 42423
> POST /session/ses_61fb303adffepX31IYrwrNVLBu/message?directory=%2Fconfig%2Fworkspace%2Fwhatsapp-mcp%2Fwhatsapp-bridge%2Fstore%2Fsessions%2F14248351223-s.whatsapp.net-c8a203c244cfad1c HTTP/1.1
> Host: localhost:42423
> User-Agent: curl/8.5.0
> Accept: */*
> Content-Type: application/json
> X-API-KEY: your_opencode_api_key_here
> Content-Length: 264
> 
} [264 bytes data]
< HTTP/1.1 400 Bad Request
< Content-Type: application/json
< Access-Control-Allow-Origin: *
< Date: Tue, 14 Oct 2025 01:22:57 GMT
< Content-Length: 112
< 
{ [112 bytes data]

100   376  100   112  100   264  14490  34157 --:--:-- --:--:-- --:--:-- 53714
* Connection #0 to host localhost left intact
{"name":"UnknownError","data":{"message":"Error: ENOENT: no such file or directory, posix_spawn '/usr/bin/rg'"}}

Environment

  • Opencode server version: 0.15.1
  • Running in Docker container

Activity

  1. github-actions commented on Oct 14, 2025

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

    Feel free to ignore if none of these address your specific case.

  2. rekram1-node commented on Oct 14, 2025

    @rekram1-node
    Collaborator

    is there anything preventing rg from installing? Maybe to solve issue just include it in your docker image?

  3. wojons commented on Oct 14, 2025

    @wojons
    Author

    even when rg was installed it saying it was not installed. The problem is that the directory flag when submitting a message shouldn't be there the server does respond with a 400 bd request but it still talks about the rg error.

  4. rekram1-node commented on Oct 14, 2025

    @rekram1-node
    Collaborator

    why all crossed out? haha

  5. wojons commented on Oct 14, 2025

    @wojons
    Author

    I crossed them out because the ?directory= can work when sending a message and it was not only installing the rg on docker but also on the host for it to start working correctly. So not sure what the right choice is for this endpoint should it be a 400 the request is not malformed but its more of a 500 server error

  6. towry commented on Oct 23, 2025

    @towry

    Have this issue with opencode 0.15.14, gpt-5 from copilot.

    List /Users/towry/Library/Application Support/neonvim/site/pack
    
    
    
    Error: ENOENT: no such file or directory, posix_spawn '/etc/profiles/per-
    user/towry/bin/rg'
    

    Working dir is ~/.config,

    subdirs:

    • neonvim
    • nvim

    /etc/profiles/per-user/towry/bin/rg did exist and valid.

  7. veracioux commented on Oct 23, 2025

    @veracioux
    Contributor

    I can reproduce when the search directory does not exist. Bun.spawn incorrectly reports that the "rg" executable does not exist, when it is in fact the cwd that doesn't exist.

  8. rekram1-node commented on Oct 23, 2025

    @rekram1-node
    Collaborator

    What a find, nice work @veracioux !!

  9. rekram1-node commented on Oct 23, 2025

    @rekram1-node
    Collaborator

    will be fixed in next release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions