Building Zed for Linux
Clone the Repository
Clone the Zed repository:Install Dependencies
Rust
Install rustup:System Libraries
Install the necessary system libraries:script/linux file.
Linkers
On Linux, Rust’s default linker is LLVM’slld. Alternative linkers, especially Wild and Mold, can improve clean and incremental build times.
Zed currently uses Mold in CI because it is more mature. For local development, Wild is recommended because it is typically 5-20% faster than Mold.
These linkers can be installed with:
Using Wild as Your Default Linker
To use Wild as your default, add these lines to your~/.cargo/config.toml:
Using Mold as Your Default Linker
To use Mold as your default:Build Zed from Source
Once the dependencies are installed, you can build Zed using Cargo.Debug Build
For a debug build of the editor:CLI in Release Mode
In release mode, the primary user interface is thecli crate. You can run it in development with:
Run Tests
To run the tests:Install a Development Build
You can install a local build on your machine with:zed and the cli in release mode, installs the binary at ~/.local/bin/zed, and installs .desktop files to ~/.local/share.
Linker Errors with aws-lc-rs
If you encounter linker errors similar to:x86_64-unknown-linux-gnu:
Wayland & X11
Zed supports both X11 and Wayland. By default, we pick whichever we can find at runtime. If you’re on Wayland and want to run in X11 mode, use the environment variable:Memory Profiling
heaptrack is quite useful for diagnosing memory leaks. To install it:
heaptrack_interpret to convert the *.raw.zst profile to a *.zst file which can be passed to heaptrack_gui for viewing.
Perf Recording
How to get a flamegraph with resolved symbols from a running Zed instance. Use this when Zed is using a lot of CPU. It is not useful for hangs.During the Incident
-
Find the PID (process ID):
Or find the PID of
zed-editorwith the highest RAM usage in htop/btop/top. -
Install perf (on Ubuntu derivatives):
-
Perf record:
Wait a few seconds to gather data, then press Ctrl+C. You should now have a
perf.datafile. -
Make the output file user owned:
-
Get build info:
Run zed again and type
zed: aboutin the command palette to get the exact commit.
perf.data file can be sent to Zed together with the exact commit.
Later (by Zed Staff)
-
Build Zed with symbols:
Check out the commit found previously and modify
Cargo.toml. Apply the following diff, then make a release build: -
Add the symbols to the perf database:
-
Resolve the symbols from the db:
-
Install flamegraph:
-
Render the flamegraph:
