Repository navigation
Closed
Description
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
- Start opencode server (running in Docker container).
- 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"}' - 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
Metadata
Metadata
Assignees
Labels
No labels
Activity
github-actions commentedon Oct 14, 2025
This issue might be a duplicate of existing issues. Please check:
rghangs indefinitely in 0.14.7 in a linux/amd64 container; works on 0.14.6 #3089: Similar ripgrep (rg) issues in containerized environments - that issue was aboutrghanging indefinitely in linux/amd64 containersFeel free to ignore if none of these address your specific case.
rekram1-node commentedon Oct 14, 2025
is there anything preventing rg from installing? Maybe to solve issue just include it in your docker image?
wojons commentedon Oct 14, 2025
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.rekram1-node commentedon Oct 14, 2025
why all crossed out? haha
wojons commentedon Oct 14, 2025
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
towry commentedon Oct 23, 2025
Have this issue with opencode 0.15.14, gpt-5 from copilot.
Working dir is
~/.config,subdirs:
/etc/profiles/per-user/towry/bin/rgdid exist and valid.veracioux commentedon Oct 23, 2025
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.
rekram1-node commentedon Oct 23, 2025
What a find, nice work @veracioux !!
rekram1-node commentedon Oct 23, 2025
will be fixed in next release