1# Building Zed for Linux
2
3## Repository
4
5Clone down the [Zed repository](https://github.com/zed-industries/zed).
6
7## Dependencies
8
9- Install [Rust](https://www.rust-lang.org/tools/install). If it's already installed, make sure it's up-to-date:
10
11 ```bash
12 rustup update
13 ```
14
15- Install the necessary system libraries:
16
17 ```bash
18 script/linux
19 ```
20
21 If you prefer to install the system libraries manually, you can find the list of required packages in the `script/linux` file.
22
23## Backend dependencies
24
25> [!WARNING]
26> This section is still in development. The instructions are not yet complete.
27
28If you are developing collaborative features of Zed, you'll need to install the dependencies of zed's `collab` server:
29
30- Install [Postgres](https://www.postgresql.org/download/linux/)
31- Install [Livekit](https://github.com/livekit/livekit-cli) and [Foreman](https://theforeman.org/manuals/3.9/quickstart_guide.html)
32
33Alternatively, if you have [Docker](https://www.docker.com/) installed you can bring up all the `collab` dependencies using Docker Compose:
34
35```sh
36docker compose up -d
37```
38
39## Building from source
40
41Once you have the dependencies installed, you can build Zed using [Cargo](https://doc.rust-lang.org/cargo/).
42
43For a debug build:
44
45```
46cargo run
47```
48
49For a release build:
50
51```
52cargo run --release
53```
54
55For a release package:
56
57```
58cargo build --release
59```
60
61the binary can be found in `target/release` folder.
62
63And to run the tests:
64
65```
66cargo test --workspace
67```
68
69## Wayland & X11
70
71Zed has basic support for both modes. The mode is selected at runtime. If you're on wayland and want to run in X11 mode, you can set `WAYLAND_DISPLAY='' cargo run` to do so.
72
73## Flatpak
74
75> [!WARNING]
76> Zed's current Flatpak integration simply exits the sandbox on startup. Workflows that rely on Flatpak's sandboxing may not work as expected.
77
78To build & install the Flatpak package locally follow the steps below:
79
801. Install Flatpak for your distribution as outlined [here](https://flathub.org/setup).
812. Run the `script/flatpak/deps` script to install the required dependencies.
823. Run `script/flatpak/bundle-flatpak`.
834. Now the package has been installed and has a bundle available at `target/release/{app-id}.flatpak`.
84
85## Troubleshooting
86
87### Can't compile zed
88
89Before reporting the issue, make sure that you have the latest rustc version with `rustup update`.
90
91### Cargo errors claiming that a dependency is using unstable features
92
93Try `cargo clean` and `cargo build`.
94
95### Vulkan/GPU issues
96
97If Zed crashes at runtime due to GPU or vulkan issues, you can try running [vkcube](https://github.com/krh/vkcube) (usually available as part of the `vulkaninfo` package on various distributions) to try to troubleshoot where the issue is coming from. Try running in both X11 and wayland modes by running `vkcube -m [x11|wayland]`. Some versions of `vkcube` use `vkcube` to run in X11 and `vkcube-wayland` to run in wayland.
98
99If you have multiple GPUs, you can also try running Zed on a different one (for example, with [vkdevicechooser](https://github.com/jiriks74/vkdevicechooser)) to figure out where the issue comes from.