Zed Remote Development on FreeBSD: Setup and Fix10 min read2,071 words

Zed Remote Development on FreeBSD: Setup and Fix

Set up Zed’s remote editor on FreeBSD with Linux compatibility, a safe uname wrapper, and the kernel fix behind the empty project tree, explained step by step.

Zed remote development FreeBSDZed remote serverFreeBSD LinuxulatorFreeBSD directory listing bugremote development setup
Zed Remote Development on FreeBSD: Setup and Fix

How to Run Zed's Remote Editor on a FreeBSD Server

Zed runs fast on your desktop, but using it to edit files on a FreeBSD machine takes a little more than pasting an SSH address. The main hurdles are pretty specific:

  1. Zed doesn't have a native FreeBSD remote server build, so it rejects the host during its platform check.
  2. Even if you get past that check, a FreeBSD kernel bug can make the remote project tree look empty.

The good news is you don't need to "turn your server into Linux" to make this work. FreeBSD can run Linux binaries via its Linux compatibility layer. Then you can use a small uname wrapper to answer just the one platform query Zed cares about - without changing how the rest of the system identifies itself. After that, a separate kernel fix handles the directory-listing problem that can follow.

This guide walks through the setup, explains why the workaround is intentionally narrow, and describes the 768-byte buffer issue that can make Zed show an empty folder. It also covers the kernel-side fix and what to check if the connection still fails.

Why Zed needs a Linux server on FreeBSD

Zed's remote workflow needs a server component running on the machine you connect to. When you open a remote folder over SSH, Zed checks the host platform and then installs or starts the matching server.

On amd64, FreeBSD reports itself as FreeBSD, and Zed doesn't ship a FreeBSD remote server build. That's obstacle number one.

FreeBSD's Linux compatibility layer gives you a practical path around that missing build. It lets Linux x86_64 binaries run on a FreeBSD host, so the Linux Zed server can run as long as the compatibility layer is set up correctly.

Obstacle number two is how Zed decides which server to install. Zed bases its choice on what uname reports. If you wrap uname so that Zed's specific query returns Linux x86_64, Zed can pick the Linux server - while all other uname calls still go through to FreeBSD's real uname.

Keeping that workaround scoped matters. If you made a broad, system-level change, you could confuse scripts, monitoring tools, or anything that expects accurate FreeBSD identifiers. A user-local wrapper in ~/.local/bin has a much smaller blast radius, and it's easy to remove later if native FreeBSD support appears or if Zed's detection changes.

So you're dealing with two independent requirements:

  • The Linux compatibility layer must be enabled and have a suitable Linux base installed.
  • Zed must see the right platform response so it selects its Linux server package.

Neither requirement fixes the directory-listing kernel bug described later. A successful SSH connection just means the client and server can talk - it doesn't prove directory enumeration works. Treat "connection setup" and "file listing" as separate parts of the diagnosis.

How to set up Zed remote development on FreeBSD

Start with a FreeBSD server you can access over SSH, where you can install packages and enable Linux compatibility. The steps below assume the setup described for the Linux x86_64 Zed server. Check your host architecture and FreeBSD release first - this isn't a one-size-fits-all recipe for every CPU or Linux binary.

Enable Linux compatibility

Enable the Linux service, start it, and install the Linux base package:

sudo sysrc linux_enable=YES

sudo service linux start

sudo pkg install linux_base-rl9

kldstat -m linux64

The last command should list the linux64 module. If it doesn't, fix the compatibility-layer or kernel-module issue before you try to debug Zed. The remote editor can't start its Linux server if the host can't actually run Linux binaries.

Add a narrow uname wrapper

Create ~/.local/bin if needed, then save this script as ~/.local/bin/uname:

#!/bin/sh

case "$#:$*" in

1:-sm|1:-ms) printf 'Linux x86_64\n' ;;

*) exec /usr/bin/uname "$@" ;;

esac

Make it executable:

chmod +x ~/.local/bin/uname

This wrapper only intercepts the single-argument -sm or -ms request. Those flags ask for the system name and machine architecture - exactly what Zed uses for its platform selection. Anything else is passed to FreeBSD's real /usr/bin/uname.

You also need this executable to be on PATH inside the non-interactive SSH session Zed uses. Interactive shell startup files aren't always read. For zsh, add this to ~/.zshenv:

export PATH="$HOME/.local/bin:$PATH"

Use the equivalent startup configuration for your shell.

The point here is simple: confirm the remote, non-interactive environment sees the wrapper. A wrapper that works in a terminal might still be invisible to Zed over SSH.

Connect and inspect the server logs

In Zed, connect to the FreeBSD host over SSH and open a folder. On the first connection, Zed uploads its Linux server to ~/.zed_server/.

If the connection starts but the folder is empty (or you see an error), check the server workspace log:

tail -f ~/.local/share/zed/logs/server-workspace-*.log

Look for directory-entry errors. A working connection doesn't automatically mean the server can browse directories correctly - this is where the kernel issue below can show up.

Why the remote project tree appeared empty

A remote editor has to enumerate directories before it can show anything. Zed asks its server for file and directory names in batches. On an affected FreeBSD kernel, the Linux compatibility layer could read a batch of directory entries larger than what the Linux program's buffer expected. The conversion step then fails, and Zed treats the directory as unreadable.

The logs often include an error like:

error processing entry failed to read directory entry

Caused by:

Invalid argument (os error 22)

That points to a directory-entry handling problem, not necessarily a wrong project path or a broken SSH login. The server can be running fine while the project browser fails to populate.

The 768-byte buffer in plain English

Think of it like a reader crossing names off on the spot while another person writes them onto a note that can only hold six names.

  • Normally, the reader calls out four at a time, so the note has room.
  • But when the last batch contains eight names, the note can't hold all eight.
  • If the reader already moved past those extra two, they can't be "read again" after the fact. The process has lost its place and has to report an error.

In the kernel bug, the Linux program provides a 768-byte buffer, and the batch size is shaped by a 512-byte block used on the FreeBSD side. When a request of 768 bytes gets rounded up to the next 512-byte boundary, the native read can become larger than what the Linux-facing buffer can hold.

FreeBSD may already advance the directory offset for the full batch before the Linux compatibility layer notices that the converted entries don't fit.

That's why "return only what fits" isn't enough after the offset has already moved on. Once the directory stream has advanced, the unread entries are gone from the stream's point of view. Testing also showed a "quiet failure" mode can omit files without warning - 112 out of 1,002 in one run.

Practical diagnostic

If:

  • SSH connects,
  • Zed's server starts, and
  • the remote folder appears empty,

then dig into the FreeBSD kernel fix. Don't keep changing the uname wrapper - it only affects platform detection, not directory enumeration.

What the FreeBSD kernel fix changes

This directory bug was a regression in the FreeBSD Linuxulator, the compatibility layer that handles Linux system calls. A February 2026 change intended to fix bogus entries returned for NFS directories altered how sys/compat/linux/linux_file.c sizes reads inside linux_getdents() and linux_getdents64().

Previously, the native read length was limited to the caller's requested count and MAXBSIZE. The changed code rounded the request up to a multiple of DEV_BSIZE (512 bytes) before applying the limit. That can be fine when the aligned larger read is still safe, but it breaks when the caller's buffer isn't also a multiple of 512 bytes. In that case, the native read can produce more data than the Linux-facing buffer can hold.

The Linux compatibility layer converts native FreeBSD directory records into Linux directory records. If a converted record doesn't fit, it reports EINVAL. But the underlying kern_getdirentries() call already advanced the directory offset for the whole batch. So you can't recover the portion that didn't fit.

The fix, identified as ec6629628cb, uses the caller's buffer size directly when the request is at least one 512-byte block. It only rounds up for smaller requests:

if (args->count >= DEV_BSIZE)

buflen = min(args->count, MAXBSIZE);

else

buflen = roundup2(args->count, DEV_BSIZE);

The reasoning is that, for the relevant layouts, Linux directory records are no larger than their FreeBSD equivalents. For dirent64, for example, the header is 19 bytes versus FreeBSD's 24, and both formats round records to an eight-byte multiple. If the native batch fits the caller's buffer, the translated records should fit too.

This correction applies to both getdents and getdents64. The initial patch covered only getdents64; expanding the fix to include both legacy and 64-bit callers reduced failures from 86 to zero. That matters because a change that works for one syscall path (or directory shape) can still leave another broken.

According to the report, the change is included in main, stable/15, and releng/15.2, and FreeBSD 15.2-RELEASE is expected to contain it. If you still see the error after installing or building a kernel with the fix, make sure the system actually booted into the new kernel:

uname -v

Then retest the remote folder and re-check the Zed server log.

Conclusion

Running Zed's remote server on FreeBSD comes down to two separate issues:

  • Linux compatibility lets the Linux Zed server binary run.
  • A narrowly scoped uname wrapper gets Zed past its platform check.

The "empty project tree" problem is a different issue. It's caused by a directory-read size mismatch in the Linuxulator, and it's addressed by a FreeBSD kernel fix.

Keep the diagnosis in that order: confirm Linux compatibility, confirm the wrapper is visible to non-interactive SSH sessions, connect, then inspect the server log and your running kernel if directory listings fail. That separation helps you avoid changing a working setup to chase the wrong problem - and it makes it easier to remove the workaround once Zed supports FreeBSD natively.

Frequently Asked Questions

Not with this setup if Zed rejects the host after detecting FreeBSD and has no native FreeBSD server build. The wrapper changes only the platform-and-architecture response used for that check, allowing Zed to select its Linux x86_64 server. It does not provide native FreeBSD support.
No. It returns `Linux x86_64` only for the single `uname -sm` or `uname -ms` request. Other calls are passed to `/usr/bin/uname` unchanged. Keeping the behavior this narrow reduces the risk of confusing unrelated tools that depend on accurate FreeBSD system information.
A working SSH connection and running Zed server do not guarantee that directory enumeration works. On affected kernels, the Linuxulator could read beyond the caller’s directory buffer, then fail while translating entries. Check the server workspace log for `error processing entry` and `Invalid argument (os error 22)`.
The fix identified as `ec6629628cb` was reported in `main`, `stable/15`, and `releng/15.2`, with 15.2-RELEASE expected to include it. Branch contents can change over time, so verify your running kernel with `uname -v` rather than relying only on the installed system version.

Related articles