Zed Server
Zed remote server on FreeBSD
MacOS Zed client + FreeBSD host, using the editors/zed port to build
zed-remote-server.
Port changes
Two changes to /usr/ports/editors/zed are required for zed-editor-1.22.0.
1. Remove files/patch-crates_gpui_src_text__system.rs
Upstream 1.22.0 defines the constant unconditionally:
pub const SUBPIXEL_VARIANTS_Y: u8 = 1;
The patch still expected the old conditional form
(cfg!(target_os = "windows") || cfg!(target_os = "linux")), so its single hunk
failed and the build stopped at the patch phase. Upstream already gives FreeBSD
the value the patch asked for, so the patch is dead. Delete it. It was untracked
in the ports git tree, so no upstream commit is involved.
2. Add files/patch-Cargo.toml
--- Cargo.toml.orig
+++ Cargo.toml
@@ -1105,10 +1105,10 @@
ui_input = { codegen-units = 1 }
zed_actions = { codegen-units = 1 }
[profile.release]
-debug = "limited"
-lto = "thin"
-codegen-units = 1
+debug = 0
+lto = false
+codegen-units = 16
[profile.release.package]
zed = { codegen-units = 16 }
Without this the build dies at the final links. [profile.release] in
Cargo.toml overrides every CARGO_PROFILE_RELEASE_* environment variable, so
the profile cannot be changed from the build command. ThinLTO plus
linker-plugin-lto on the zed and remote_server binaries exceeded memory on
a 32 GB host with 4 GB swap and both were killed with signal: 9, SIGKILL.
Build command
cd /usr/ports/editors/zed
sudo env ALLOW_UNSUPPORTED_SYSTEM=yes WITHOUT_LTO=yes MAKE_JOBS_NUMBER=2 make package
MAKE_JOBS_NUMBER=2is the working jobs knob.Mk/Uses/cargo.mk:139forcesCARGO_BUILD_JOBS=${MAKE_JOBS_NUMBER}, so passingCARGO_BUILD_JOBSdirectly is overridden.WITHOUT_LTO=yesdisables the extra-C linker-plugin-ltothat ports adds atMk/Uses/cargo.mk:149.ALLOW_UNSUPPORTED_SYSTEM=yesis required because the host release is past the ports support window.- After a failed build, run
make cleanfirst. A stalework/tree re-applies patches that are already applied and fails with7 out of 7 hunks ignored.
Result: /usr/ports/editors/zed/work/pkg/zed-editor-1.22.0.pkg (112.9 MB).
Install it:
sudo pkg install /usr/ports/editors/zed/work/pkg/zed-editor-1.22.0.pkg
This installs zed-remote-server-stable-1.22.0+stable to /usr/local/bin/.
Enabling the remote server
1. Match the versions
The client looks for ~/.zed_server/zed-remote-server-stable-<version>+stable
on the remote host and requires <version> to equal its own version exactly. A
mismatch makes it download a prebuilt Linux server, which does not run on
FreeBSD.
Check the macOS client version:
/Applications/Zed.app/Contents/MacOS/zed --version
Install the port build whose DISTVERSION matches it (currently 1.20.2 is
installed, 1.22.0 is built).
2. Work around client-side OS detection
The client parses uname -sm over SSH in crates/remote/src/transport.rs and
only accepts Darwin and Linux. On FreeBSD it fails with
Prebuilt remote servers are not yet available for "FreeBSD" before it
checks whether the binary is already present. The FreeBSD port patches this in,
but an official macOS binary does not have the patch.
Shadow uname on the FreeBSD host so it reports Linux only for -sm:
mkdir -p ~/.bin
cat > ~/.bin/uname <<'EOF'
#!/bin/sh
case "$1" in
-sm) echo "Linux x86_64" ;;
*) exec /usr/bin/uname "$@" ;;
esac
EOF
chmod +x ~/.bin/uname
printf 'PATH=$HOME/.bin:$PATH\n' > ~/.ssh/environment
The client runs uname through a non-interactive shell, so shell rc files are
never sourced. ~/.ssh/environment requires this in /etc/ssh/sshd_config:
PermitUserEnvironment yes
then sudo service sshd restart.
Check it:
ssh user@freebsd-host uname -sm
# Linux x86_64
3. Upload the binary
ssh user@freebsd-host mkdir -p ~/.zed_server
scp /usr/local/bin/zed-remote-server-stable-<version>+stable user@freebsd-host:~/.zed_server/
If you did not install the port on the remote host, copy it from
work/stage/usr/local/bin/ instead.
4. Connect from the client
ctrl-cmd-shift-o(Remote Projects).- Connect New Server.
- Enter the SSH command, for example
ssh user@freebsd-host.
Set this for the server so a client upgrade never replaces the FreeBSD binary with a Linux one:
{ "upload_binary_over_ssh": true }
Limitations
- No realtime collaboration:
webrtc-syshas no FreeBSD build, so audio calls and screen sharing are disabled. - The integrated terminal is laggy on FreeBSD.
unamemust keep reporting Linux until the macOS client carries FreeBSD inRemoteOs.- Only x86_64 is known to work.