'; }
Bug 293816 - editors/zed: crashes soon after opening the directory containing any .typ files
Summary: editors/zed: crashes soon after opening the directory containing any .typ files
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: Hiroki Tagato
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2026-03-14 23:10 UTC by John Holloway
Modified: 2026-03-15 03:52 UTC (History)
0 users

See Also:
tagattie: maintainer-feedback+


Attachments
Patch file for crates/extension_host/src/wasm_host/wit/since_v0_8_0.rs (542 bytes, text/plain)
2026-03-14 23:10 UTC, John Holloway
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description John Holloway 2026-03-14 23:10:54 UTC
Created attachment 268812 [details]
Patch file for crates/extension_host/src/wasm_host/wit/since_v0_8_0.rs

After installing the Typst extension and its respective LSP,  TinyMist, Zed would crash soon after opening the directory containing any .typ files.

After running Zed from the command line with the --foreground flag and setting env RUST_BACKTRACE=1 I was able to find the cause of the crash:

thread 'tokio-runtime-worker' (146651) panicked at crates/extension_host/src/wasm_host/wit/since_v0_8_0.rs:840:22:
unsupported os
stack backtrace:
note: Some details are omitted, run with RUST_BACKTRACE=full for a verbose backtrace.

The cause of the panic is a match statement inside of the current_platform() function inside of crates/extension_host/src/wasm_host/wit/since_v0_8_0.rs   Because FreeBSD is not in the list of supported operating systems the function panics.  

impl platform::Host for WasmState {
    async fn current_platform(&mut self) -> Result<(platform::Os, platform::Architecture)> {
        Ok((
            match env::consts::OS {
                "macos" => platform::Os::Mac,
                "linux" => platform::Os::Linux,
                "windows" => platform::Os::Windows,
                _ => panic!("unsupported os"),
            },
           // ... omitted
     }      
}
The solution to this bug can be found by adding the string "freebsd" to the list of supported systems, and returning the enum platform::Os::Linux as many of these extensions work well due to FreeBSD's similar ABI and Linux Compatibility Layer. 
"linux" | "freebsd"  => platform::Os::Linux,

This will address the error and prevent the crash. This also resolves the same crash for any other WASM-based extension that calls current_platform(), including the LaTeX, HTML, GLSL, and typos extensions.

Please see the attached patch file
Comment 1 commit-hook freebsd_committerfreebsd_triage 2026-03-15 03:51:15 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=69d3298212af8b1583c4f3958ef7f4ad19ca5463

commit 69d3298212af8b1583c4f3958ef7f4ad19ca5463
Author:     John Holloway <mail@jholloway.dev>
AuthorDate: 2026-03-15 03:47:46 +0000
Commit:     Hiroki Tagato <tagattie@FreeBSD.org>
CommitDate: 2026-03-15 03:47:46 +0000

    editors/zed: Fix WASM extension host panic on FreeBSD ("unsupported os")

    Zed's WASM extension host panics with "unsupported os" on FreeBSD when
    any Rust-based extension (Typst, LaTeX, HTML, typos, etc.) loads. The
    panic occurs at
    crates/extension_host/src/wasm_host/wit/since_v0_8_0.rs:840 where
    current_platform() only handles macOS, Linux, and Windows.

    The patch maps FreeBSD to the Linux OS variant and seems to solve the
    issue, allowing the user to install the extensions for Typst, LaTex,
    and typos.

    PR:             293816
    Reported by:    John Holloway <mail@jholloway.dev>
    Pull Request:   https://github.com/tagattie/FreeBSD-Zed/pull/3

 editors/zed/Makefile                                          |  1 +
 ...xtension__host_src_wasm__host_wit_since__v0__8__0.rs (new) | 11 +++++++++++
 2 files changed, 12 insertions(+)
Comment 2 Hiroki Tagato freebsd_committerfreebsd_triage 2026-03-15 03:52:47 UTC
Committed. Thanks for your contribution!