Skip to content

Commit fce811b

Browse files
authored
fix: most segfaults on windows with Bun v1.3.10 stable (#15181)
1 parent aae75b3 commit fce811b

File tree

6 files changed

+12
-63
lines changed

6 files changed

+12
-63
lines changed
Lines changed: 2 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
name: "Setup Bun"
22
description: "Setup Bun with caching and install dependencies"
3-
inputs:
4-
cross-compile:
5-
description: "Pre-cache canary cross-compile binaries for all targets"
6-
required: false
7-
default: "false"
83
runs:
94
using: "composite"
105
steps:
@@ -21,12 +16,13 @@ runs:
2116
shell: bash
2217
run: |
2318
if [ "$RUNNER_ARCH" = "X64" ]; then
19+
V=$(node -p "require('./package.json').packageManager.split('@')[1]")
2420
case "$RUNNER_OS" in
2521
macOS) OS=darwin ;;
2622
Linux) OS=linux ;;
2723
Windows) OS=windows ;;
2824
esac
29-
echo "url=https://github.com/oven-sh/bun/releases/download/canary/bun-${OS}-x64-baseline.zip" >> "$GITHUB_OUTPUT"
25+
echo "url=https://github.com/oven-sh/bun/releases/download/bun-v${V}/bun-${OS}-x64-baseline.zip" >> "$GITHUB_OUTPUT"
3026
fi
3127
3228
- name: Setup Bun
@@ -35,54 +31,6 @@ runs:
3531
bun-version-file: ${{ !steps.bun-url.outputs.url && 'package.json' || '' }}
3632
bun-download-url: ${{ steps.bun-url.outputs.url }}
3733

38-
- name: Pre-cache canary cross-compile binaries
39-
if: inputs.cross-compile == 'true'
40-
shell: bash
41-
run: |
42-
BUN_VERSION=$(bun --revision)
43-
if echo "$BUN_VERSION" | grep -q "canary"; then
44-
SEMVER=$(echo "$BUN_VERSION" | sed 's/^\([0-9]*\.[0-9]*\.[0-9]*\).*/\1/')
45-
echo "Bun version: $BUN_VERSION (semver: $SEMVER)"
46-
CACHE_DIR="$HOME/.bun/install/cache"
47-
mkdir -p "$CACHE_DIR"
48-
TMP_DIR=$(mktemp -d)
49-
for TARGET in linux-aarch64 linux-x64 linux-x64-baseline linux-aarch64-musl linux-x64-musl linux-x64-musl-baseline darwin-aarch64 darwin-x64 windows-x64 windows-x64-baseline; do
50-
DEST="$CACHE_DIR/bun-${TARGET}-v${SEMVER}"
51-
if [ -f "$DEST" ]; then
52-
echo "Already cached: $DEST"
53-
continue
54-
fi
55-
URL="https://github.com/oven-sh/bun/releases/download/canary/bun-${TARGET}.zip"
56-
echo "Downloading $TARGET from $URL"
57-
if curl -sfL -o "$TMP_DIR/bun.zip" "$URL"; then
58-
unzip -qo "$TMP_DIR/bun.zip" -d "$TMP_DIR"
59-
if echo "$TARGET" | grep -q "windows"; then
60-
BIN_NAME="bun.exe"
61-
else
62-
BIN_NAME="bun"
63-
fi
64-
mv "$TMP_DIR/bun-${TARGET}/$BIN_NAME" "$DEST"
65-
chmod +x "$DEST"
66-
rm -rf "$TMP_DIR/bun-${TARGET}" "$TMP_DIR/bun.zip"
67-
echo "Cached: $DEST"
68-
# baseline bun resolves "bun-darwin-x64" to the baseline cache key
69-
# so copy the modern binary there too
70-
if [ "$TARGET" = "darwin-x64" ]; then
71-
BASELINE_DEST="$CACHE_DIR/bun-darwin-x64-baseline-v${SEMVER}"
72-
if [ ! -f "$BASELINE_DEST" ]; then
73-
cp "$DEST" "$BASELINE_DEST"
74-
echo "Cached (baseline alias): $BASELINE_DEST"
75-
fi
76-
fi
77-
else
78-
echo "Skipped: $TARGET (not available)"
79-
fi
80-
done
81-
rm -rf "$TMP_DIR"
82-
else
83-
echo "Not a canary build ($BUN_VERSION), skipping pre-cache"
84-
fi
85-
8634
- name: Install dependencies
8735
run: bun install
8836
shell: bash

.github/workflows/publish.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,6 @@ jobs:
7777
fetch-tags: true
7878

7979
- uses: ./.github/actions/setup-bun
80-
with:
81-
cross-compile: "true"
8280

8381
- name: Setup git committer
8482
id: committer
@@ -90,7 +88,7 @@ jobs:
9088
- name: Build
9189
id: build
9290
run: |
93-
./packages/opencode/script/build.ts --all
91+
./packages/opencode/script/build.ts
9492
env:
9593
OPENCODE_VERSION: ${{ needs.version.outputs.version }}
9694
OPENCODE_RELEASE: ${{ needs.version.outputs.release }}

.github/workflows/sign-cli.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,10 @@ jobs:
2020
fetch-tags: true
2121

2222
- uses: ./.github/actions/setup-bun
23-
with:
24-
cross-compile: "true"
2523

2624
- name: Build
2725
run: |
28-
./packages/opencode/script/build.ts --all
26+
./packages/opencode/script/build.ts
2927
3028
- name: Upload unsigned Windows CLI
3129
id: upload_unsigned_windows_cli

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"description": "AI-powered development tool",
55
"private": true,
66
"type": "module",
7-
"packageManager": "bun@1.3.9",
7+
"packageManager": "bun@1.3.10",
88
"scripts": {
99
"dev": "bun run --cwd packages/opencode --conditions=browser src/index.ts",
1010
"dev:desktop": "bun --cwd packages/desktop tauri dev",

packages/desktop/scripts/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export const SIDECAR_BINARIES: Array<{ rustTarget: string; ocBinary: string; ass
88
},
99
{
1010
rustTarget: "x86_64-apple-darwin",
11-
ocBinary: "opencode-darwin-x64",
11+
ocBinary: "opencode-darwin-x64-baseline",
1212
assetExt: "zip",
1313
},
1414
{

packages/opencode/script/build.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ const migrations = await Promise.all(
5656
)
5757
console.log(`Loaded ${migrations.length} migrations`)
5858

59-
const singleFlag = process.argv.includes("--single") || (!!process.env.CI && !process.argv.includes("--all"))
59+
const singleFlag = process.argv.includes("--single")
6060
const baselineFlag = process.argv.includes("--baseline")
6161
const skipInstall = process.argv.includes("--skip-install")
6262

@@ -103,6 +103,11 @@ const allTargets: {
103103
os: "darwin",
104104
arch: "x64",
105105
},
106+
{
107+
os: "darwin",
108+
arch: "x64",
109+
avx2: false,
110+
},
106111
{
107112
os: "win32",
108113
arch: "x64",

0 commit comments

Comments
 (0)