-
Notifications
You must be signed in to change notification settings - Fork 1
Description
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
shuvcodefrom a directory that has its ownbunfig.tomlwith:preload = ["@opentui/solid/preload"]
- Bun reads the CWD's
bunfig.tomland tries to apply preloads - Bun attempts to resolve
@opentui/solid/preloadfrom shuvcode's installation location (not the CWD) - Resolution fails because
@opentui/solidis a dependency of the local project, not the global shuvcode installation
Relevant files:
packages/opencode/bunfig.toml:1- shuvcode's own preload configurationpackages/opencode/package.json:84-@opentui/soliddependency
Acceptance Criteria
- shuvcode can be launched from any directory, regardless of whether that directory has a
bunfig.tomlwith preloads - The fix should work for both globally installed (
bun install -g) and locally linked shuvcode - No regression in TUI functionality (SolidJS transforms must still work)
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.tomlto hashbang scripts from linked packages" - Similar issue: oven-sh/bun#12539 - "
bunfig.tomlcannot findpreloadscript 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.tomlcontaining: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"