Problem
When running shuvcode from within other OpenTUI SolidJS projects, the CLI fails immediately with:
error: preload not found "@opentui/solid/preload"
This does not happen with upstream opencode, and does not happen in other (non-OpenTUI) repositories.
Root Cause
This is caused by a known Bun bug (oven-sh/bun#25442): Bun applies the current working directory's bunfig.toml to hashbang scripts from linked/global packages.
How it happens:
- shuvcode is installed globally or linked
- User runs
shuvcode from a directory that has its own bunfig.toml with:
preload = ["@opentui/solid/preload"]
- Bun reads the CWD's
bunfig.toml and tries to apply preloads
- Bun attempts to resolve
@opentui/solid/preload from shuvcode's installation location (not the CWD)
- Resolution fails because
@opentui/solid is a dependency of the local project, not the global shuvcode installation
Relevant files:
packages/opencode/bunfig.toml:1 - shuvcode's own preload configuration
packages/opencode/package.json:84 - @opentui/solid dependency
Acceptance Criteria
Potential Solutions
Option 1: Environment variable to disable config inheritance (Workaround)
Bun respects BUN_CONFIG_FILE - setting it to an empty value or a specific path might prevent CWD config loading:
# In the launcher script
BUN_CONFIG_FILE="" shuvcode "$@"
Reference: Bun config docs
Option 2: Move preload registration into the binary
Instead of relying on bunfig.toml, register the SolidJS plugin programmatically at startup:
// In src/index.ts or entry point
import { plugin } from "bun"
import solidTransformPlugin from "@opentui/solid/bun-plugin"
plugin(solidTransformPlugin)
This is what the preload script already does - see packages/opencode/node_modules/@opentui/solid/scripts/preload.ts:
import solidTransformPlugin from "./solid-plugin"
import { plugin, type BunPlugin } from "bun"
plugin(solidTransformPlugin)
Note: This approach requires careful consideration of module loading order.
Option 3: Use --config flag with explicit config path
Modify the launcher script to explicitly specify the config file:
bun --config /path/to/shuvcode/bunfig.toml run ...
Option 4: Wait for Bun fix
The upstream issue oven-sh/bun#25442 is open and describes this exact problem. However, there's no timeline for a fix.
Related Issues
- Upstream Bun issue: oven-sh/bun#25442 - "Bun applies cwd's
bunfig.toml to hashbang scripts from linked packages"
- Similar issue: oven-sh/bun#12539 - "
bunfig.toml cannot find preload script that doesn't begin with './'"
Environment
- shuvcode version: 1.0.223+
- Bun version: 1.3.x
- Platform: Linux/macOS
Steps to Reproduce
- Have a project with
bunfig.toml containing:
preload = ["@opentui/solid/preload"]
- Install shuvcode globally:
bun install -g shuvcode
- Navigate to the project directory
- Run
shuvcode
- Observe the error:
error: preload not found "@opentui/solid/preload"
Problem
When running
shuvcodefrom within other OpenTUI SolidJS projects, the CLI fails immediately with:This does not happen with upstream
opencode, and does not happen in other (non-OpenTUI) repositories.Root Cause
This is caused by a known Bun bug (oven-sh/bun#25442): Bun applies the current working directory's
bunfig.tomlto hashbang scripts from linked/global packages.How it happens:
shuvcodefrom a directory that has its ownbunfig.tomlwith:bunfig.tomland tries to apply preloads@opentui/solid/preloadfrom shuvcode's installation location (not the CWD)@opentui/solidis a dependency of the local project, not the global shuvcode installationRelevant files:
packages/opencode/bunfig.toml:1- shuvcode's own preload configurationpackages/opencode/package.json:84-@opentui/soliddependencyAcceptance Criteria
bunfig.tomlwith preloadsbun install -g) and locally linked shuvcodePotential Solutions
Option 1: Environment variable to disable config inheritance (Workaround)
Bun respects
BUN_CONFIG_FILE- setting it to an empty value or a specific path might prevent CWD config loading:Reference: Bun config docs
Option 2: Move preload registration into the binary
Instead of relying on
bunfig.toml, register the SolidJS plugin programmatically at startup:This is what the preload script already does - see
packages/opencode/node_modules/@opentui/solid/scripts/preload.ts:Note: This approach requires careful consideration of module loading order.
Option 3: Use
--configflag with explicit config pathModify the launcher script to explicitly specify the config file:
Option 4: Wait for Bun fix
The upstream issue oven-sh/bun#25442 is open and describes this exact problem. However, there's no timeline for a fix.
Related Issues
bunfig.tomlto hashbang scripts from linked packages"bunfig.tomlcannot findpreloadscript that doesn't begin with './'"Environment
Steps to Reproduce
bunfig.tomlcontaining:bun install -g shuvcodeshuvcodeerror: preload not found "@opentui/solid/preload"