Skip to content

The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.

fix(typst): install pinned Windows x64 release under Git Bash (#1768)

0xdiego25ee95d52742a7
diff --git a/store/agents/typst/.gitattributes b/store/agents/typst/.gitattributes
new file mode 100644
index 000000000..ed50e5a0b
--- /dev/null
+++ b/store/agents/typst/.gitattributes
@@ -0,0 +1,3 @@
+# Bash must parse these on Linux, macOS and Git Bash, even with core.autocrlf.
+toolchain/*.sh text eol=lf
+TYPST_VERSION text eol=lf
diff --git a/store/agents/typst/README.md b/store/agents/typst/README.md
index d79a320d2..15e9e5e35 100644
--- a/store/agents/typst/README.md
+++ b/store/agents/typst/README.md
@@ -17,6 +17,21 @@ Typst revision. [How document review works](../../viewers/doc-viewer/README.md#c
the pane header.
- `template/` — a fresh workspace: `main.typ`, `assets/`, `out/`.
+## Windows setup
+
+Windows x64 is supported through Git Bash (MINGW/MSYS), with `curl`, `sha256sum`
+and `unzip` on PATH. Setup installs the official ZIP's
+`typst-x86_64-pc-windows-msvc/typst.exe` as `bin/typst.exe`; Git Bash and native
+Windows Python also resolve the manifest's `bin/typst` path. A working `python3`
+is required for the verdict (the Microsoft Store alias alone is insufficient).
+Linux and macOS continue to use their pinned `.tar.xz` releases.
+
+The Windows v0.15.1 ZIP's SHA-256 is
+`19ce3551153c2fe7ee9fa2f95208310c8f4d3209fedb699e0333faf8913f6736`,
+verified against the `digest` field in the
+[official release API](https://api.github.com/repos/typst/typst/releases/tags/v0.15.1)
+and the downloaded archive.
+
## Credit and stewardship
Typst is Typst GmbH's — Laurenz Mädje and Martin Haug — [typst/typst](https://github.com/typst/typst),
diff --git a/store/agents/typst/toolchain/doctor.sh b/store/agents/typst/toolchain/doctor.sh
index 46ac97c7f..22d850935 100755
--- a/store/agents/typst/toolchain/doctor.sh
+++ b/store/agents/typst/toolchain/doctor.sh
@@ -1,4 +1,4 @@
#!/usr/bin/env bash
set -u; cd "$(dirname "$0")/.."
if [ -x bin/typst ]; then echo "ok $(bin/typst --version)"; else echo "miss bin/typst — run toolchain/setup.sh"; exit 1; fi
-if command -v python3 >/dev/null 2>&1; then echo "ok $(python3 --version) for the verdict"; else echo "miss python3 for the verdict"; exit 1; fi
+if PYTHON_VERSION="$(python3 --version 2>/dev/null)"; then echo "ok $PYTHON_VERSION for the verdict"; else echo "miss python3 for the verdict"; exit 1; fi
diff --git a/store/agents/typst/toolchain/setup.sh b/store/agents/typst/toolchain/setup.sh
index a3d7bc9ec..70080bb1e 100755
--- a/store/agents/typst/toolchain/setup.sh
+++ b/store/agents/typst/toolchain/setup.sh
@@ -7,21 +7,31 @@ cd "$(dirname "$0")/.."
VERSION="$(cat TYPST_VERSION)"
# GitHub's own digests for the release assets. They move with TYPST_VERSION: a bump pins them anew.
SUMS_FOR=v0.15.1
+BINARY=typst
case "$(uname -s)-$(uname -m)" in
Darwin-arm64) ASSET="typst-aarch64-apple-darwin.tar.xz" SUM=48f62ed034aa3a7978309579ac6ca00045e2ef0da73114e8af27cfd8e74dc05a ;;
Darwin-x86_64) ASSET="typst-x86_64-apple-darwin.tar.xz" SUM=7f9fdd9584866245de9a79e0add8f9236fae6f40a8a45e2c4771ccc14db4e0fa ;;
Linux-x86_64) ASSET="typst-x86_64-unknown-linux-musl.tar.xz" SUM=a6d077d0a95eed5a2eba715b2dae06be954f624ccbf85758a03f389ded33118c ;;
Linux-aarch64) ASSET="typst-aarch64-unknown-linux-musl.tar.xz" SUM=5aa8d74a3d906e60ea12a66ac2f37f8eef1b14cbad7182a745e393a10c23dcee ;;
+ MINGW*-x86_64|MSYS*-x86_64)
+ ASSET="typst-x86_64-pc-windows-msvc.zip" SUM=19ce3551153c2fe7ee9fa2f95208310c8f4d3209fedb699e0333faf8913f6736
+ BINARY=typst.exe ;;
*) echo "miss no Typst release for $(uname -s)-$(uname -m)"; exit 1 ;;
esac
-if [ -x bin/typst ] && bin/typst --version 2>/dev/null | grep -q "${VERSION#v}"; then echo "ok typst ${VERSION} already here"; exit 0; fi
+if [ -x "bin/$BINARY" ] && "bin/$BINARY" --version 2>/dev/null | grep -q "${VERSION#v}"; then echo "ok typst ${VERSION} already here"; exit 0; fi
[ "$VERSION" = "$SUMS_FOR" ] || { echo "miss the checksums in toolchain/setup.sh are for typst ${SUMS_FOR}, not ${VERSION}"; exit 1; }
+if [ "$BINARY" = typst.exe ] && ! command -v unzip >/dev/null 2>&1; then
+ echo "miss unzip — install Git Bash with unzip to extract the Windows release"; exit 1
+fi
mkdir -p bin tmp
echo " downloading typst ${VERSION} (${ASSET})"
URL="https://github.com/typst/typst/releases/download/${VERSION}/${ASSET}"
curl -fsSL --retry 3 -o "tmp/${ASSET}" "$URL" || { rm -rf tmp; echo "miss could not download $URL — check this machine's internet connection"; exit 1; }
if command -v shasum >/dev/null 2>&1; then GOT="$(shasum -a 256 "tmp/${ASSET}" | cut -d' ' -f1)"; else GOT="$(sha256sum "tmp/${ASSET}" | cut -d' ' -f1)"; fi
[ "$GOT" = "$SUM" ] || { rm -rf tmp; echo "miss ${ASSET} did not match its pinned checksum; nothing was installed"; exit 1; }
-tar -xJf "tmp/${ASSET}" -C tmp
-cp "tmp/${ASSET%.tar.xz}/typst" bin/typst && chmod +x bin/typst && rm -rf tmp
-echo "ok $(bin/typst --version)"
+case "$ASSET" in
+ *.zip) unzip -q "tmp/${ASSET}" -d tmp; RELEASE_DIR="${ASSET%.zip}" ;;
+ *) tar -xJf "tmp/${ASSET}" -C tmp; RELEASE_DIR="${ASSET%.tar.xz}" ;;
+esac
+cp "tmp/${RELEASE_DIR}/${BINARY}" "bin/${BINARY}" && chmod +x "bin/${BINARY}" && rm -rf tmp
+echo "ok $("bin/${BINARY}" --version)"
diff --git a/store/agents/typst/toolchain/test_scripts.py b/store/agents/typst/toolchain/test_scripts.py
index eebcd9b2a..96125dd7c 100644
--- a/store/agents/typst/toolchain/test_scripts.py
+++ b/store/agents/typst/toolchain/test_scripts.py
@@ -78,6 +78,14 @@ class Doctor(unittest.TestCase):
self.assertEqual(r.returncode, 1)
self.assertEqual(r.stdout.splitlines()[-1], "miss python3 for the verdict")
+ def test_broken_python_alias_is_a_miss(self):
+ box = Sandbox(self)
+ box.stub("typst", 'echo "typst 0.15.1"', where=box.install / "bin")
+ box.stub("python3", "exit 9009")
+ r = box.run("doctor.sh")
+ self.assertEqual(r.returncode, 1)
+ self.assertEqual(r.stdout.splitlines()[-1], "miss python3 for the verdict")
+
class Setup(unittest.TestCase):
def sandbox(self, system="Darwin", machine="arm64") -> Sandbox:
@@ -86,6 +94,7 @@ class Setup(unittest.TestCase):
# curl writes the archive it was asked for; tar unpacks a typst that knows its version.
box.stub("curl", 'while [ $# -gt 1 ]; do [ "$1" = -o ] && out="$2"; shift; done; echo archive > "$out"')
box.stub("tar", f'dir="$4/$(basename "$2" .tar.xz)"; mkdir -p "$dir"; printf \'#!/bin/bash\\necho "typst {VERSION[1:]} (fetched)"\\n\' > "$dir/typst"')
+ box.stub("unzip", f'dir="$4/$(basename "$2" .zip)"; mkdir -p "$dir"; printf \'#!/bin/bash\\necho "typst {VERSION[1:]} (fetched)"\\n\' > "$dir/typst.exe"')
(box.bin / "basename").symlink_to("/usr/bin/basename")
self.sha("shasum")
return box
@@ -119,6 +128,42 @@ class Setup(unittest.TestCase):
self.assertEqual((r.returncode, r.stdout.splitlines()[-1]), (0, f"ok typst {VERSION[1:]} (fetched)"), r.stderr)
self.assertIn("sha256sum tmp/typst-x86_64-unknown-linux-musl.tar.xz", box.logged())
+ def test_windows_zip_on_mingw_and_msys(self):
+ for system in ("MINGW64_NT-10.0-26200", "MSYS_NT-10.0-26200"):
+ with self.subTest(system=system):
+ box = self.sandbox(system, "x86_64")
+ (box.bin / "shasum").unlink()
+ self.sha("sha256sum")
+ r = box.run("setup.sh")
+ self.assertEqual(r.returncode, 0, r.stderr)
+ self.assertTrue(os.access(box.install / "bin/typst.exe", os.X_OK))
+ self.assertIn("unzip -q tmp/typst-x86_64-pc-windows-msvc.zip -d tmp", box.logged())
+ self.assertFalse(any(c.startswith("tar ") for c in box.logged()))
+ self.assertFalse((box.install / "tmp").exists())
+ r = box.run("setup.sh")
+ self.assertEqual(r.stdout.strip(), f"ok typst {VERSION} already here")
+ self.assertEqual(sum(c.startswith("curl ") for c in box.logged()), 1)
+
+ def test_windows_bad_checksum_is_not_unzipped(self):
+ box = self.sandbox("MINGW64_NT-10.0", "x86_64")
+ r = box.run("setup.sh", BAD_SUM="0" * 64)
+ self.assertEqual(r.returncode, 1)
+ self.assertFalse(any(c.startswith("unzip ") for c in box.logged()))
+ self.assertFalse((box.install / "bin/typst.exe").exists())
+
+ def test_windows_needs_unzip_before_download(self):
+ box = self.sandbox("MSYS_NT-10.0", "x86_64")
+ (box.bin / "unzip").unlink()
+ r = box.run("setup.sh")
+ self.assertEqual(r.returncode, 1)
+ self.assertIn("miss unzip", r.stdout)
+ self.assertFalse(any(c.startswith("curl ") for c in box.logged()))
+
+ def test_windows_arm_is_not_mistaken_for_x64(self):
+ r = self.sandbox("MINGW64_NT-10.0", "aarch64").run("setup.sh")
+ self.assertEqual(r.returncode, 1)
+ self.assertIn("miss no Typst release", r.stdout)
+
def test_an_archive_that_does_not_match_its_checksum_is_never_unpacked(self):
box = self.sandbox()
r = box.run("setup.sh", BAD_SUM="0" * 64)