Files
zed/docs/src/development/linux.md
T
yenru0 74405573c9 gwen: Rebrand documentation to Gwen
Rewrite product prose and local path/command examples across the docs
to match the shipped application (gwen CLI, Gwen config paths, Gwen.app,
com.yrkaierx.Gwen). Upstream distribution channels, service URLs and
package identifiers stay factually intact.
2026-09-29 09:24:34 +09:00

7.9 KiB

title, description
title description
Building Gwen for Linux Guide to building Gwen for Linux.

Building Gwen for Linux

Repository

Clone the Zed repository.

Dependencies

  • Install rustup

  • Install the necessary system libraries:

    script/linux
    

    If you prefer to install the system libraries manually, you can find the list of required packages in the script/linux file.

Building from source

Once the dependencies are installed, you can build Gwen using Cargo.

For a debug build of the editor:

cargo run

And to run the tests:

cargo test --workspace

In release mode, the primary user interface is the cli crate. You can run it in development with:

cargo run -p cli

Installing a development build

You can install a local build on your machine with:

./script/install-linux

This builds zed and the cli in release mode, installs the binary at ~/.local/bin/gwen, and installs .desktop files to ~/.local/share.

Wayland & X11

Gwen 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 WAYLAND_DISPLAY=''.

Notes for packaging Gwen

This section is for distribution maintainers packaging Gwen.

Technical requirements

Gwen has two main binaries:

  • You will need to build crates/cli and make its binary available in $PATH with the name gwen.
  • You will need to build crates/zed and put it at $PATH/to/cli/../../libexec/gwen. For example, if you are going to put the cli at ~/.local/bin/gwen put the editor binary at ~/.local/libexec/gwen. As some linux distributions (notably Arch) discourage the use of libexec, you can also put this binary at $PATH/to/cli/../../lib/gwen/gwen (e.g. ~/.local/lib/gwen/gwen) instead.
  • If you are going to provide a .desktop file you can find a template in crates/zed/resources/gwen.desktop.in, and use envsubst to populate it with the values required. This file should also be renamed to $APP_ID.desktop so that the file follows the FreeDesktop standards. You should also make this desktop file executable (chmod 755).
  • You will need to ensure that the necessary libraries are installed. You can get the current list by inspecting the built binary on your system.
  • For an example of a complete build script, see script/bundle-linux.
  • You can disable Gwen's auto updates and provide instructions for users who try to update Gwen manually by building (or running) Gwen with the environment variable ZED_UPDATE_EXPLANATION. For example: ZED_UPDATE_EXPLANATION="Please use flatpak to update gwen.".
  • Make sure to update the contents of the crates/zed/RELEASE_CHANNEL file to 'nightly', 'preview', or 'stable', with no newline. This will cause Gwen to use the credentials manager to remember a user's login.

Other things to note

Gwen moves quickly, and distribution maintainers often have different constraints and priorities. The points below describe current trade-offs:

  • Gwen is a fast-moving project. We typically publish 2-3 builds per week to address reported issues and ship larger changes.
  • There are a couple of unrelated zed binaries that may be present on Linux systems (1, 2). The Gwen CLI binary is named gwen, so it does not conflict with them.
  • Gwen automatically installs versions of common developer tools, similar to rustup/rbenv/pyenv. This behavior is discussed here.
  • Users can install extensions locally and from zed-industries/extensions. Extensions may install additional tools such as language servers. Planned safety improvements are tracked here.
  • Gwen connects to several online services by default (AI, telemetry, collaboration). AI and our telemetry can be disabled by your users with their Gwen settings or by patching our default settings file.
  • Because of the points above, Gwen currently does not work well with sandboxes. See this discussion.

Flatpak

Gwen's current Flatpak integration exits the sandbox on startup. Workflows that rely on Flatpak's sandboxing may not work as expected.

To build & install the Flatpak package locally follow the steps below:

  1. Install Flatpak for your distribution as outlined here.
  2. Run the script/flatpak/deps script to install the required dependencies.
  3. Run script/flatpak/bundle-flatpak.
  4. Now the package has been installed and has a bundle available at target/release/{app-id}.flatpak.

Memory profiling

heaptrack is quite useful for diagnosing memory leaks. To install it:

$ sudo apt install heaptrack heaptrack-gui
$ cargo install cargo-heaptrack

Then, to build and run Gwen with the profiler attached:

$ cargo heaptrack -b gwen

When this Gwen instance is exited, terminal output will include a command to run 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 Gwen instance. Use this when Gwen is using a lot of CPU. It is not useful for hangs.

During the incident

  • Find the PID (process ID) using: ps -eo size,pid,comm | grep gwen | sort | head -n 1 | cut -d ' ' -f 2 Or find the PID of gwen with the highest RAM usage in something like htop/btop/top.

  • Install perf: On Ubuntu (derivatives) run sudo apt install linux-tools.

  • Perf record: Run sudo perf record -g --call-graph dwarf -p <pid you just found>, wait a few seconds to gather data, then press Ctrl+C. You should now have a perf.data file. The --call-graph dwarf option records callers of every sampled function and unwinds through the .eh_frame data kept in stripped release binaries; plain -g does not work without frame pointers.

  • Make the output file user owned: run sudo chown $USER:$USER perf.data

  • Get build info: Run zed again and type {#action zed::About} in the command pallet to get the exact commit.

The perf.data file can be sent to Gwen together with the exact commit.

Later

This can be done by Zed staff.

Released Linux binaries are stripped, but the unstripped binary for every release is archived in Sentry (uploaded by script/bundle-linux). Download it from the Sentry project's Debug Files page (search by the release version or the binary's build id), then continue with the perf buildid-cache step below. Stripping preserves the build id, so the downloaded binary matches the user's perf.data.

Alternatively, rebuild the binary with symbols:

  • Check out the commit found previously and modify Cargo.toml. Apply the following diff, then make a release build.
[profile.release]
-debug = "limited"
+debug = "full"
  • Add the symbols to the perf database: perf buildid-cache -v -a <path to release gwen binary>

  • Resolve the symbols from the db: perf inject -i perf.data -o perf_with_symbols.data

  • Install flamegraph: cargo install cargo-flamegraph

  • Render the flamegraph: flamegraph --perfdata perf_with_symbols.data

Troubleshooting

Cargo errors claiming that a dependency is using unstable features

Try cargo clean and cargo build.