Skip to content

cli: opencode always opens ~ instead of requested directory (/api/location 500 with null-byte shell path) #49997

Closed

Description

@marcos2872

Summary

opencode v2.0.10 ignores the target directory and always opens ~ instead (e.g. opencode /home/marcos/Projetos/fingerprint-manager, cd ... && opencode, and session_move all stay/fall back to /home/marcos). Underneath, GET /api/location and GET /api/fs/list return HTTP 500 caused by mkdir on a shell path containing 40 null bytes. Same commands work in /tmp and ~.

Environment

  • opencode version: v2.0.10
  • OS: Linux fedora 7.2.5-200.fc44.x86_64 feat: compact and other improvements #1 SMP PREEMPT_DYNAMIC Fri Sep 11 15:11:05 UTC 2026 x86_64 GNU/Linux
  • Terminal: TERM=xterm-256color, COLORTERM=truecolor, TERM_PROGRAM=(empty)
  • Shell: /bin/bash
  • Install/channel: latest (local=false, opencode service status → shared background service)
  • Active plugins: none found in config (~/.config/opencode/opencode.jsonc contains only $schema, no project .opencode/)

Reproduction

  1. cd /home/marcos/Projetos/fingerprint-manager (a git repo with .git/ but no origin remote — git remote get-url origin → error: No such remote 'origin')
  2. Run any of:
    • opencode
    • opencode /home/marcos/Projetos/fingerprint-manager
    • opencode --standalone
    • opencode run "diga ok"
  3. Observe failure. Control case: cd /tmp && opencode run "diga ok" succeeds.

Expected Behavior

opencode opens with working directory /home/marcos/Projetos/fingerprint-manager, session_move to that directory succeeds, and /api/location + /api/fs/list return 200.

Actual Behavior

  • TUI with --standalone aborts:
    UnknownError: An error occurred in Effect.tryPromise ... ClientError: UnexpectedStatus {"status":500}
  • opencode run in project dir → Error: UnexpectedStatus
  • session_move to project dir → Unable to move session to /home/marcos/Projetos/fingerprint-manager
  • Server log shows:
    session move destination unavailable directory=/home/marcos/Projetos/fingerprint-manager

Additional Context

Server log excerpts (~/.local/share/opencode/log/opencode.log):

cause="TypeError: The argument 'path' must be a string, Uint8Array, or URL without null bytes. Received \"/home/marcos/.local/share/opencode/shell/\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\"
    at mkdir (unknown)
    at mkdir (node:fs/promises:247:21)"
http.method=GET http.url=/api/fs/list http.status=500
http.method=GET http.url=/api/location http.status=500

Same 40-null-byte path in both endpoints. Consistently reproducible for this directory (tried opencode, opencode ./, opencode /abs/path, --standalone, run, session_move, service restart). Works in /tmp and /home/marcos. No workaround found. Possibly related to git repo without origin, but not confirmed — /tmp (non-git) works.

Activity

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