diff --git a/packages/adapter-utils/src/sandbox-install-command.ts b/packages/adapter-utils/src/sandbox-install-command.ts index 33cf92da909..d8ef0767d25 100644 --- a/packages/adapter-utils/src/sandbox-install-command.ts +++ b/packages/adapter-utils/src/sandbox-install-command.ts @@ -24,8 +24,8 @@ const ENSURE_NPM_PREAMBLE = 'mkdir -p "$HOME/.local"; ' + 'curl -fsSL "https://nodejs.org/dist/${NODE_VERSION}/${NODE_TARBALL}" -o "/tmp/${NODE_TARBALL}" && ' + 'tar -xJf "/tmp/${NODE_TARBALL}" -C "$HOME/.local" --strip-components=1 && ' + - 'rm -f "/tmp/${NODE_TARBALL}"; ' + - 'export PATH="$HOME/.local/bin:$PATH"; ' + + 'rm -f "/tmp/${NODE_TARBALL}" && ' + + 'export PATH="$HOME/.local/bin:$PATH" && ' + "PAPERCLIP_NPM_BOOTSTRAPPED=1; " + "fi;"; diff --git a/packages/adapters/opencode-local/src/index.ts b/packages/adapters/opencode-local/src/index.ts index 647dc61a17f..6f36e378e6f 100644 --- a/packages/adapters/opencode-local/src/index.ts +++ b/packages/adapters/opencode-local/src/index.ts @@ -12,8 +12,11 @@ export const label = "OpenCode (local)"; // `$HOME/.opencode/bin` and tries to add it to PATH via `~/.bashrc`. That // rc-file path is only sourced by interactive/login shells, so non-login // `sh -c` probe invocations (used by the runtime PATH check) cannot find the -// binary. We fix that by symlinking the installed binary into -// `$HOME/.local/bin`, which is on the default PATH on every distro we target. +// binary. We fix that by symlinking the installed binary into a directory on +// the non-login `sh -c` PATH: prefer `/usr/local/bin` (universally on the +// default PATH on Linux distros) when root or passwordless sudo is available, +// otherwise fall back to `$HOME/.local/bin` (which is on the default PATH on +// the exe.dev sandbox image and most modern home-managed Linux images). // // Security tradeoff: this is `curl | bash` without a SHA-256 verification of // the install script. We accept this because: @@ -30,9 +33,15 @@ export const label = "OpenCode (local)"; // a versioned tarball + verifying the digest before exec. export const SANDBOX_INSTALL_COMMAND = 'curl -fsSL https://opencode.ai/install | bash && ' + - 'mkdir -p "$HOME/.local/bin" && ' + 'if [ -x "$HOME/.opencode/bin/opencode" ]; then ' + + 'if [ "$(id -u)" -eq 0 ]; then ' + + 'ln -sf "$HOME/.opencode/bin/opencode" /usr/local/bin/opencode; ' + + 'elif command -v sudo >/dev/null 2>&1 && sudo -n true >/dev/null 2>&1; then ' + + 'sudo ln -sf "$HOME/.opencode/bin/opencode" /usr/local/bin/opencode; ' + + 'else ' + + 'mkdir -p "$HOME/.local/bin" && ' + 'ln -sf "$HOME/.opencode/bin/opencode" "$HOME/.local/bin/opencode"; ' + + 'fi; ' + 'fi'; export const DEFAULT_OPENCODE_LOCAL_MODEL = "openai/gpt-5.2-codex";