3
43
Fork
You've already forked opencode.el
16

Unable to run commands like ls (ENOENT: no such file or directory, posix_spawn '/bin/zsh') #5

Closed
opened 2026年01月15日 10:28:49 +01:00 by fast-90 · 5 comments

Using opencode.el, my LLM is unable to run commands like ls, which also makes it unable to see what is in the working directory/repo. I says the following:

The bash tool is unable to execute commands due to a shell access issue. The working directory is listed as ~/repos/kairos/ but I cannot access it to list files.

> What error do you get if you try ls?

I get ENOENT: no such file or directory, posix_spawn '/bin/zsh' when trying to run ls or any bash command. This indicates the system cannot find or access the shell (/bin/zsh) to execute commands.

I am running Emacs 31.0.50, MacOS, opencode 1.1.21.

Using opencode.el, my LLM is unable to run commands like `ls`, which also makes it unable to see what is in the working directory/repo. I says the following: > The bash tool is unable to execute commands due to a shell access issue. The working directory is listed as `~/repos/kairos/` but I cannot access it to list files. > > \> What error do you get if you try ls? > > I get `ENOENT: no such file or directory, posix_spawn '/bin/zsh'` when trying to run `ls` or any bash command. This indicates the system cannot find or access the shell (`/bin/zsh`) to execute commands. I am running Emacs 31.0.50, MacOS, opencode 1.1.21.
Owner
Copy link

I think this is caused by having an unexpanded ~ in the directory we send to opencode. On my machine default-directory always seems expanded, but it looks like in emacs it's allowed to have ~ in it. I added a couple calls to expand-file-name so we shouldn't send ~ anymore, in bac1921, does that fix it for you?

I think this is caused by having an unexpanded `~` in the directory we send to opencode. On my machine `default-directory` always seems expanded, but it looks like in emacs it's allowed to have `~` in it. I added a couple calls to `expand-file-name` so we shouldn't send `~` anymore, in bac1921, does that fix it for you?
Author
Copy link

@sczi wrote in #5 (comment):

I think this is caused by having an unexpanded ~ in the directory we send to opencode. On my machine default-directory always seems expanded, but it looks like in emacs it's allowed to have ~ in it. I added a couple calls to expand-file-name so we shouldn't send ~ anymore, in bac1921, does that fix it for you?

Unfortunately not, I still have the same issue:

image

This is on the current main branch, which has the bac1921 commit.

@sczi wrote in https://codeberg.org/sczi/opencode.el/issues/5#issuecomment-9889328: > I think this is caused by having an unexpanded `~` in the directory we send to opencode. On my machine `default-directory` always seems expanded, but it looks like in emacs it's allowed to have `~` in it. I added a couple calls to `expand-file-name` so we shouldn't send `~` anymore, in [`bac1921`](/sczi/opencode.el/commit/bac1921), does that fix it for you? Unfortunately not, I still have the same issue: ![image](/attachments/6b3e223e-9cbb-4106-9aaf-3297cb4ce8a0) This is on the current main branch, which has the `bac1921` commit.
115 KiB
Owner
Copy link

Can you check what is the value of default-directory in that session buffer? Maybe it is still ~/... and I missed somewhere I need to call expand-file-name. Though also if the session buffer was created before that latest commit, it would still have been created with ~, if it has ~ is it an old buffer or is it still created with ~ in default-directory after restarting emacs? Also I assume you already checked but in the TUI it is working, you don't have the same issue?

Can you check what is the value of `default-directory` in that session buffer? Maybe it is still `~/...` and I missed somewhere I need to call `expand-file-name`. Though also if the session buffer was created before that latest commit, it would still have been created with `~`, if it has `~` is it an old buffer or is it still created with `~` in `default-directory` after restarting emacs? Also I assume you already checked but in the TUI it is working, you don't have the same issue?
Owner
Copy link

in 337d54e I added a variable opencode-show-tool-output you can set to t to display the output of bash commands, maybe that will help to get the exact error message to debug it. It's not meant to be a permanent feature, eventually I'd like to make the tool outputs collapsed by default but you can click to show the full output. for now though opencode-show-tool-output can help with debugging

in 337d54e I added a variable `opencode-show-tool-output` you can set to t to display the output of bash commands, maybe that will help to get the exact error message to debug it. It's not meant to be a permanent feature, eventually I'd like to make the tool outputs collapsed by default but you can click to show the full output. for now though `opencode-show-tool-output` can help with debugging
Author
Copy link

This works now after I pulled the main branch this morning, thanks!

This works now after I pulled the main branch this morning, thanks!
Sign in to join this conversation.
No Branch/Tag specified
main
No results found.
Labels
Clear labels
No items
No labels
Milestone
Clear milestone
No items
No milestone
Projects
Clear projects
No items
No project
Assignees
Clear assignees
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
sczi/opencode.el#5
Reference in a new issue
sczi/opencode.el
No description provided.
Delete branch "%!s()"

Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?