Skip to content

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

Closed

Description

@brianluby

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

Activity

  1. github-actions commented on Sep 14, 2025

    @github-actions
    Contributor

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

    • Can't init my project #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.

  2. rekram1-node commented on Sep 14, 2025

    @rekram1-node
    Collaborator

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

    Does it work without creating dir if you do:

    opencode .
    
  3. brianluby commented on Sep 14, 2025

    @brianluby
    Author

    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.

  4. brianluby commented on Sep 14, 2025

    @brianluby
    Author

    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.

  5. thdxr commented on Sep 14, 2025

    @thdxr
    Member

    what OS + version is this?

  6. rekram1-node commented on Sep 14, 2025

    @rekram1-node
    Collaborator

    In the op it says:

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

  7. nicoburniske commented on Sep 14, 2025

    @nicoburniske

    also happens on nixos + opencode 0.8.0

    doing opencode . works however

  8. ndrwstn commented on Sep 15, 2025

    @ndrwstn

    Also on macOS 15.6.1; I've been doing

    opencode `pwd`<tab>

    to have my window appropriately labeled.

  9. rekram1-node commented on Nov 20, 2025

    @rekram1-node
    Collaborator

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

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