opencode fails when opencode/ subdirectory is missing from repo #1711

Closed
opened 2026-02-16 17:32:17 -05:00 by yindo · 9 comments
Owner

Originally created by @brianluby on GitHub (Sep 14, 2025).

Originally assigned to: @thdxr on GitHub.

Summary:
opencode fails to run in directories that don't contain an opencode/ subdirectory, with a misleading error message that doesn't explain the actual requirement.
Steps to Reproduce:

Navigate to any directory without an opencode/ subdirectory
Ensure opencode is properly authenticated (opencode auth login)
Run opencode

Expected Behavior:

opencode should either create the required opencode/ directory automatically, OR
Provide a clear error message explaining that an opencode/ directory is required and how to resolve it

Actual Behavior:
Error: Failed to change directory to /path/to/current/directory/opencode

Environment:

Directory tested: /opt/personal-repos/dev-stack and ~/personal-repos/dev-stack (symlink)
Authentication: Successfully completed with Claude
OS: cachyOS (arch based linux)
opencode version: 0.7.9

Workaround:
mkdir opencode
opencode # now works

Additional Notes:

The error message is misleading - initially appeared to be a symlink resolution issue
No documentation found explaining the opencode/ directory requirement
Error occurs regardless of symlinks (tested in both symlinked and direct paths)

Installation method: AUR via yay
Package version: 0.7.9-1

Originally created by @brianluby on GitHub (Sep 14, 2025). Originally assigned to: @thdxr on GitHub. Summary: opencode fails to run in directories that don't contain an opencode/ subdirectory, with a misleading error message that doesn't explain the actual requirement. Steps to Reproduce: Navigate to any directory without an opencode/ subdirectory Ensure opencode is properly authenticated (opencode auth login) Run opencode Expected Behavior: opencode should either create the required opencode/ directory automatically, OR Provide a clear error message explaining that an opencode/ directory is required and how to resolve it Actual Behavior: Error: Failed to change directory to /path/to/current/directory/opencode Environment: Directory tested: /opt/personal-repos/dev-stack and ~/personal-repos/dev-stack (symlink) Authentication: Successfully completed with Claude OS: cachyOS (arch based linux) opencode version: 0.7.9 Workaround: mkdir opencode opencode # now works Additional Notes: The error message is misleading - initially appeared to be a symlink resolution issue No documentation found explaining the opencode/ directory requirement Error occurs regardless of symlinks (tested in both symlinked and direct paths) Installation method: AUR via yay Package version: 0.7.9-1
yindo closed this issue 2026-02-16 17:32:17 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Sep 14, 2025):

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

  • #2269: Similar "Failed to change directory" error when trying to initialize projects, though that was with the opencode init command specifically

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

@github-actions[bot] commented on GitHub (Sep 14, 2025): This issue might be a duplicate of existing issues. Please check: - #2269: Similar "Failed to change directory" error when trying to initialize projects, though that was with the `opencode init` command specifically Feel free to ignore if none of these address your specific case.
Author
Owner

@rekram1-node commented on GitHub (Sep 14, 2025):

I think this is some bun bug I have seen this before...

Does it work without creating dir if you do:

opencode .
@rekram1-node commented on GitHub (Sep 14, 2025): I think this is some bun bug I have seen this before... Does it work without creating dir if you do: ``` opencode . ```
Author
Owner

@brianluby commented on GitHub (Sep 14, 2025):

You are correct that worked. I rm -rf'd the opencode dir and then tried opencode no period and it failed same message and then tried with the period opencode . and it worked fine in the symlinked directory.

@brianluby commented on GitHub (Sep 14, 2025): You are correct that worked. I rm -rf'd the opencode dir and then tried opencode no period and it failed same message and then tried with the period opencode . and it worked fine in the symlinked directory.
Author
Owner

@brianluby commented on GitHub (Sep 14, 2025):

But in both cases running /init came back with directory errors. Albeit the second time a lot less.

Read .github/copilot-instructions.md

Error: ENOENT: no such file or directory, scandir '/opt/personal-repos/dev-stack/.github'

The previous run without teh period have 5-10 of the /opt/ errors and I was in the symlink ~/personal-repos/dev-stack/

Not sure how exactly bun is being uses but this is deeper than just the initial setup.

@brianluby commented on GitHub (Sep 14, 2025): But in both cases running /init came back with directory errors. Albeit the second time a lot less. Read .github/copilot-instructions.md Error: ENOENT: no such file or directory, scandir '/opt/personal-repos/dev-stack/.github' The previous run without teh period have 5-10 of the /opt/ errors and I was in the symlink ~/personal-repos/dev-stack/ Not sure how exactly bun is being uses but this is deeper than just the initial setup.
Author
Owner

@thdxr commented on GitHub (Sep 14, 2025):

what OS + version is this?

@thdxr commented on GitHub (Sep 14, 2025): what OS + version is this?
Author
Owner

@rekram1-node commented on GitHub (Sep 14, 2025):

In the op it says:

OS: cachyOS (arch based linux)
opencode version: 0.7.9

@rekram1-node commented on GitHub (Sep 14, 2025): In the op it says: <br><br>OS: cachyOS (arch based linux) <br>opencode version: 0.7.9
Author
Owner

@nicoburniske commented on GitHub (Sep 14, 2025):

also happens on nixos + opencode 0.8.0

doing opencode . works however

@nicoburniske commented on GitHub (Sep 14, 2025): also happens on nixos + opencode 0.8.0 doing `opencode .` works however
Author
Owner

@ndrwstn commented on GitHub (Sep 14, 2025):

Also on macOS 15.6.1; I've been doing

opencode `pwd`<tab>

to have my window appropriately labeled.

@ndrwstn commented on GitHub (Sep 14, 2025): Also on macOS 15.6.1; I've been doing ```bash opencode `pwd`<tab> ``` to have my window appropriately labeled.
Author
Owner

@rekram1-node commented on GitHub (Nov 20, 2025):

I think this was fixed, lmk if u still have this issue

@rekram1-node commented on GitHub (Nov 20, 2025): I think this was fixed, lmk if u still have this issue
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#1711