opencode icon indicating copy to clipboard operation
opencode copied to clipboard

missing documentation for how to run from source

Open aspiers opened this issue 3 weeks ago • 6 comments

AFAICS, there is nothing in any of README.md, CONTRIBUTING.md, https://opencode.ai/docs#install etc. explaining how to run OpenCode from source on another repository, i.e. whilst having the working directory be a different repo other than OpenCode itself.

Fixing this is really important if you want more people to help test (and even develop against) the latest development branches.

I spent several few hours bashing my head against this problem. Eventually I searched the OpenCode Discord chat history and found some breadcrumbs to follow which led me to #3764 and then #3778. Unfortunately however neither of those PRs added / updated any docs.

With extra help from OpenCode, I concluded that this approach works and seems to be correct:

# Save the path to the code we want to run OpenCode against
orig_cwd="$(pwd)"

# Now we can switch to the opencode repo...
cd "$OPENCODE_REPO"
# ... and pass the target directory as a parameter to bun:
bun dev "$orig_cwd" "$@"

Is this right?

aspiers avatar Dec 29 '25 22:12 aspiers

If you wanna run it for a different dir:

bun dev dir

If you just wanna run it in root of opencode repo:

bun dev .

And if you wanna compile it and have a local executable (a localcode if you will):

./packages/opencode/script/build.ts --single

then run like so (for me this is):

./packages/opencode/dist/opencode-darwin-arm64/bin/opencode

rekram1-node avatar Dec 29 '25 23:12 rekram1-node

I can update docs tho

rekram1-node avatar Dec 29 '25 23:12 rekram1-node

/oc use docs agent to update CONTRIBUTING.md to include this

rekram1-node avatar Dec 29 '25 23:12 rekram1-node

Created PR #6405

New%20session%20-%202025-12-29T23%3A03%3A52.145Z opencode session  |  github run

opencode-agent[bot] avatar Dec 29 '25 23:12 opencode-agent[bot]

How is this?

https://github.com/sst/opencode/blob/dev/CONTRIBUTING.md#running-against-a-different-directory

rekram1-node avatar Dec 29 '25 23:12 rekram1-node

I have this: ~/.local/bin/opencode

#!/bin/bash
set -eo pipefail

PROJECT_DIR=$(pwd)
cd ~/repos/opencode
exec bun dev --dir "$PROJECT_DIR" $@

# Proposed alternative syntax: https://github.com/paralin/opencode/commit/81275b1af11ccf51d20578765e2acf1db08caf0d
# exec bun run --cwd packages/opencode --conditions=browser src/index.ts --dir $PROJECT_DIR $@

paralin avatar Dec 30 '25 00:12 paralin

Awesome thanks a lot @rekram1-node!

aspiers avatar Jan 01 '26 19:01 aspiers