Skip to content

Commit dcb4aa4

Browse files
committed
Fix install-dev to copy binary directly instead of bun install -g
1 parent 6850f89 commit dcb4aa4

1 file changed

Lines changed: 41 additions & 3 deletions

File tree

install-dev

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,33 @@ clone_or_update_repo() {
6868
print_message success "Repository ready"
6969
}
7070

71+
detect_platform() {
72+
local raw_os=$(uname -s)
73+
case "$raw_os" in
74+
Darwin*) os="darwin" ;;
75+
Linux*) os="linux" ;;
76+
MINGW*|MSYS*|CYGWIN*) os="windows" ;;
77+
*) os=$(echo "$raw_os" | tr '[:upper:]' '[:lower:]') ;;
78+
esac
79+
80+
arch=$(uname -m)
81+
if [[ "$arch" == "aarch64" ]]; then
82+
arch="arm64"
83+
fi
84+
if [[ "$arch" == "x86_64" ]]; then
85+
arch="x64"
86+
fi
87+
88+
if [ "$os" = "darwin" ] && [ "$arch" = "x64" ]; then
89+
rosetta_flag=$(sysctl -n sysctl.proc_translated 2>/dev/null || echo 0)
90+
if [ "$rosetta_flag" = "1" ]; then
91+
arch="arm64"
92+
fi
93+
fi
94+
95+
PLATFORM="$os-$arch"
96+
}
97+
7198
build_and_install() {
7299
print_message info "${MUTED}Installing dependencies...${NC}"
73100
bun install
@@ -76,10 +103,21 @@ build_and_install() {
76103
cd "$CLONE_DIR/packages/opencode"
77104
bun run build
78105

79-
print_message info "${MUTED}Installing globally...${NC}"
106+
print_message info "${MUTED}Installing binary...${NC}"
80107
mkdir -p "$INSTALL_DIR"
81-
cd "$CLONE_DIR"
82-
bun install -g ./packages/opencode
108+
109+
detect_platform
110+
local binary_path="$CLONE_DIR/packages/opencode/dist/opencode-$PLATFORM/bin/opencode"
111+
112+
if [ ! -f "$binary_path" ]; then
113+
print_message error "Binary not found for platform: $PLATFORM"
114+
print_message info "Available platforms:"
115+
ls "$CLONE_DIR/packages/opencode/dist/"
116+
exit 1
117+
fi
118+
119+
cp "$binary_path" "$INSTALL_DIR/opencode"
120+
chmod 755 "$INSTALL_DIR/opencode"
83121

84122
print_message success "Build complete"
85123
}

0 commit comments

Comments
 (0)