Skip to content

cli: models and session listing hang instead of erroring when the cwd does not exist on the server #62682

Open

Description

@zawawa-art

Summary

When --server points at a remote server and the client's cwd does not exist on that server, opencode models and session listing hang with no output instead of returning an error. Aligning the client cwd with an existing path on the server makes both commands respond immediately.

Environment

  • opencode version: 2.2.6 (client and server)
  • OS (server): Darwin 27.0.0 arm64 (macOS)
  • OS (client): Ubuntu 24.04.5 LTS (x86_64), cloud VM
  • Terminal: non-interactive / no TTY (scripted invocation)
  • Shell: /bin/bash (GNU bash 5.2.21)
  • Install/channel: server via Homebrew (latest); client via the official v2 installer (https://opencode.ai/v2/install), npm package @opencode/cli-linux-x64 installed to ~/.opencode/bin
  • Active plugins: none

Reproduction

  1. Start opencode serve --hostname 0.0.0.0 --port 4096 on the server.
  2. On the client, run opencode --server http://<server>:4096 models from a directory path that does not exist on the server.
  3. Observe: no output, no error, indefinite hang.
  4. Run the same command from a path that exists on the server (for example /Users/<user>/project); it returns immediately.

Expected Behavior

A clear error such as "location/directory does not exist on the server", or a fallback to a valid directory.

Actual Behavior

Indefinite hang with no output and no error.

Additional Context

  • The client's cwd is sent as the session location.directory; the server cannot resolve it and the request never completes.
  • Workaround: cd to a path that exists on the server, or pass an explicit directory where supported.
  • Suggestion: validate the location on the server and fail fast.

Activity

  1. opencodejr commented on Nov 8, 2026

    @opencodejr
    Contributor

    Thanks for the detailed report! I tried this on 2.2.6 with a Linux server and a client cwd the server can't see. Both commands failed straight away with a clear error instead of hanging:

    • opencode --server … models printed LocationNotFoundError: Location not found: <dir>
    • opencode session list --server … printed Location not found: <dir>

    That's the expected behaviour: the server checks the directory and should answer with LocationNotFoundError. So the hang probably depends on something in your setup, most likely the macOS server, which I can't test here. One possible cause: on macOS, /home is managed by the automounter, so if your client cwd is something like /home/ubuntu/..., checking that path on the server might stall. That's a guess, not something I've confirmed.

    A maintainer with a macOS server will need to look at this. A few details would help:

    • The exact client cwd that hangs, e.g. /home/ubuntu/... or something else.
    • Whether it still hangs from a missing path outside /home, e.g. mkdir -p /tmp/nope/x && cd /tmp/nope/x && opencode --server http://<server>:4096 models.
    • Whether curl to the server works quickly from that client, to rule out the network path you described in cli: run hangs before creating a session when the initial SSE event is buffered #62681.

    Related: #62681 (same setup, run hangs on a buffered event stream) and #62469 (clearer errors for invalid session locations).

  2. r266-tech commented on Nov 8, 2026

    @r266-tech
    Contributor

    I tested the official @opencode/[email protected] binary on macOS 27.3 arm64 with isolated configuration and storage. On direct loopback, /api/location and /api/model returned HTTP 404 LocationNotFoundError for both missing paths:

    • /private/tmp/oss-cwd-does-not-exist-62682: 12–16 ms
    • /home/ubuntu/opencode-62682-missing: 207–236 ms

    I also ran the real models and session list commands through a loopback pass-through proxy that substituted those paths in location[directory]. Both exited with status 1 and the location error in 62–243 ms; the existing-directory controls exited 0. No model requests were made.

    This does not reproduce the remote tunnel or Darwin 27.0 environment in the report. A local request on the affected server, using the exact client cwd, would help distinguish filesystem validation from the network path:

    curl --max-time 10 -u "opencode:$OPENCODE_PASSWORD" --get \
      --data-urlencode 'location[directory]=/home/ubuntu/REPLACE_WITH_EXACT_CLIENT_CWD' \
      http://127.0.0.1:4096/api/location

    AI-assisted investigation.

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

Metadata

Metadata

Assignees

No one assigned

    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