Skip to content

Commit 9599fc7

Browse files
committed
fix: correct tarball handling
1 parent c936e92 commit 9599fc7

File tree

2 files changed

+25
-4
lines changed

2 files changed

+25
-4
lines changed

registry/coder/modules/cmux/main.test.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,12 @@ describe("cmux", async () => {
2222
state,
2323
"alpine/curl",
2424
"sh",
25-
"apk add bash tar gzip",
25+
"apk add --no-cache bash tar gzip ca-certificates findutils nodejs && update-ca-certificates",
2626
);
27-
27+
if (output.exitCode !== 0) {
28+
console.log("STDOUT:\n" + output.stdout.join("\n"));
29+
console.log("STDERR:\n" + output.stderr.join("\n"));
30+
}
2831
expect(output.exitCode).toBe(0);
2932
const expectedLines = [
3033
"📥 npm not found; downloading tarball from npm registry...",
@@ -35,7 +38,7 @@ describe("cmux", async () => {
3538
for (const line of expectedLines) {
3639
expect(output.stdout).toContain(line);
3740
}
38-
}, 15000);
41+
}, 60000);
3942

4043
it("runs with npm present", async () => {
4144
const state = await runTerraformApply(import.meta.dir, {

registry/coder/modules/cmux/run.sh

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,28 @@ if [ ! -f "$CMUX_BINARY" ] || [ "${USE_CACHED}" != true ]; then
9090
exit 1
9191
fi
9292
CANDIDATE=""
93+
# Common locations
9394
if [ -f "$TMP_DIR/package/bin/cmux" ]; then
9495
CANDIDATE="$TMP_DIR/package/bin/cmux"
96+
elif [ -f "$TMP_DIR/package/bin/cmux.js" ]; then
97+
CANDIDATE="$TMP_DIR/package/bin/cmux.js"
98+
elif [ -f "$TMP_DIR/package/bin/cmux.mjs" ]; then
99+
CANDIDATE="$TMP_DIR/package/bin/cmux.mjs"
95100
else
96-
CANDIDATE="$(find "$TMP_DIR/package" -maxdepth 3 -type f -name "cmux" | head -n1)"
101+
# Try to read package.json bin field
102+
if [ -f "$TMP_DIR/package/package.json" ]; then
103+
BIN_PATH=$(sed -n 's/.*"bin"[[:space:]]*:[[:space:]]*"\([^"]*\)".*/\1/p' "$TMP_DIR/package/package.json" | head -n1)
104+
if [ -z "$BIN_PATH" ]; then
105+
BIN_PATH=$(sed -n '/"bin"[[:space:]]*:[[:space:]]*{/,/}/p' "$TMP_DIR/package/package.json" | sed -n 's/.*"cmux"[[:space:]]*:[[:space:]]*"\([^"]*\)".*/\1/p' | head -n1)
106+
fi
107+
if [ -n "$BIN_PATH" ] && [ -f "$TMP_DIR/package/$BIN_PATH" ]; then
108+
CANDIDATE="$TMP_DIR/package/$BIN_PATH"
109+
fi
110+
fi
111+
# Fallback: search for plausible filenames
112+
if [ -z "$CANDIDATE" ] || [ ! -f "$CANDIDATE" ]; then
113+
CANDIDATE=$(find "$TMP_DIR/package" -maxdepth 4 -type f \( -name "cmux" -o -name "cmux.js" -o -name "cmux.mjs" -o -name "cmux.cjs" \) | head -n1)
114+
fi
97115
fi
98116
if [ -z "$CANDIDATE" ] || [ ! -f "$CANDIDATE" ]; then
99117
echo "❌ Could not locate cmux binary in tarball"

0 commit comments

Comments
 (0)