opencode icon indicating copy to clipboard operation
opencode copied to clipboard

OpenCode executes `bunfig.toml` preload scripts from the working directory

Open m1yon opened this issue 1 month ago • 4 comments

Description

When starting OpenCode in a directory that contains a bunfig.toml file with a preload configuration, OpenCode incorrectly executes the specified preload scripts. This causes unexpected behavior, such as running setup scripts intended for the project's runtime environment, not the editor/agent environment.

Expected behavior

OpenCode should not load or execute the project's bunfig.toml preload scripts during its own startup. It should run in isolation from the project's runtime configuration.

OpenCode version

1.0.143

Steps to reproduce

  1. Create a project directory with a bunfig.toml file.
  2. Add a preload script to bunfig.toml:
preload = ["./src/setup.ts"]
  1. Create the corresponding script (e.g., src/setup.ts) with some side effects (e.g., logging, network requests, or process.exit()).
  2. Start OpenCode in this directory.
  3. Observe that the preload script is executed.

Screenshot and/or share link

No response

Operating System

macOS 15.6.1 (Build 24G90)

Terminal

Ghostty

m1yon avatar Dec 10 '25 23:12 m1yon

thanks, will fix

rekram1-node avatar Dec 11 '25 00:12 rekram1-node

This is weird, I can replicate but I don't know what's causing it, we clearly set the flag here to disable it: https://github.com/sst/opencode/blob/26d0280f70760a1212636683c1b5753afa4e70d8/packages/opencode/script/build.ts#L118

rekram1-node avatar Dec 19 '25 04:12 rekram1-node

Might be a bun bug, adding label if anyoen can investigate this deeper

rekram1-node avatar Dec 19 '25 06:12 rekram1-node