1# Building Zed for Windows
2
3> The following commands may be executed in any shell.
4
5## Repository
6
7Clone down the [Zed repository](https://github.com/zed-industries/zed).
8
9## Dependencies
10
11- Install [Rust](https://www.rust-lang.org/tools/install). If it's already installed, make sure it's up-to-date:
12
13 ```sh
14 rustup update
15 ```
16
17- Install the Rust wasm toolchain:
18
19 ```sh
20 rustup target add wasm32-wasip1
21 ```
22
23- Install [Visual Studio](https://visualstudio.microsoft.com/downloads/) with the optional component `MSVC v*** - VS YYYY C++ x64/x86 build tools` (`v***` is your VS version and `YYYY` is year when your VS was released)
24- Install Windows 11 or 10 SDK depending on your system, but ensure that at least `Windows 10 SDK version 2104 (10.0.20348.0)` is installed on your machine. You can download it from the [Windows SDK Archive](https://developer.microsoft.com/windows/downloads/windows-sdk/)
25- Install [CMake](https://cmake.org/download)
26
27## Backend dependencies
28
29> This section is still in development. The instructions are not yet complete.
30
31If you are developing collaborative features of Zed, you'll need to install the dependencies of zed's `collab` server:
32
33- Install [Postgres](https://www.postgresql.org/download/windows/)
34- Install [Livekit](https://github.com/livekit/livekit-cli) and [Foreman](https://theforeman.org/manuals/3.9/quickstart_guide.html)
35
36Alternatively, if you have [Docker](https://www.docker.com/) installed you can bring up all the `collab` dependencies using Docker Compose:
37
38```sh
39docker compose up -d
40```
41
42## Building from source
43
44Once you have the dependencies installed, you can build Zed using [Cargo](https://doc.rust-lang.org/cargo/).
45
46For a debug build:
47
48```sh
49cargo run
50```
51
52For a release build:
53
54```sh
55cargo run --release
56```
57
58And to run the tests:
59
60```sh
61cargo test --workspace
62```
63
64## Installing from msys2
65
66[MSYS2](https://msys2.org/) distribution provides Zed as a package [mingw-w64-zed](https://packages.msys2.org/base/mingw-w64-zed). The package is available for UCRT64 and CLANG64. To download it, run
67
68```sh
69pacman -Syu
70pacman -S $MINGW_PACKAGE_PREFIX-zed
71```
72
73then you can run `zed` in a shell.
74
75You can see the [build script](https://github.com/msys2/MINGW-packages/blob/master/mingw-w64-zed/PKGBUILD) for more details on build process.
76
77> Please, report any issue in [msys2/MINGW-packages/issues](https://github.com/msys2/MINGW-packages/issues?q=is%3Aissue+is%3Aopen+zed) first.
78
79## Troubleshooting
80
81### Can't compile zed
82
83Before reporting the issue, make sure that you have the latest rustc version with `rustup update`.
84
85### Cargo errors claiming that a dependency is using unstable features
86
87Try `cargo clean` and `cargo build`.
88
89### `STATUS_ACCESS_VIOLATION`
90
91This error can happen if you are using the "rust-lld.exe" linker. Consider trying a different linker.
92
93If you are using a global config, consider moving the Zed repository to a nested directory and add a `.cargo/config.toml` with a custom linker config in the parent directory.
94
95See this issue for more information [#12041](https://github.com/zed-industries/zed/issues/12041)
96
97### Invalid RC path selected
98
99Sometimes, depending on the security rules applied to your laptop, you may get the following error while compiling Zed:
100
101```
102error: failed to run custom build command for `zed(C:\Users\USER\src\zed\crates\zed)`
103
104Caused by:
105 process didn't exit successfully: `C:\Users\USER\src\zed\target\debug\build\zed-b24f1e9300107efc\build-script-build` (exit code: 1)
106 --- stdout
107 cargo:rerun-if-changed=../../.git/logs/HEAD
108 cargo:rustc-env=ZED_COMMIT_SHA=25e2e9c6727ba9b77415588cfa11fd969612adb7
109 cargo:rustc-link-arg=/stack:8388608
110 cargo:rerun-if-changed=resources/windows/app-icon.ico
111 package.metadata.winresource does not exist
112 Selected RC path: 'bin\x64\rc.exe'
113
114 --- stderr
115 The system cannot find the path specified. (os error 3)
116warning: build failed, waiting for other jobs to finish...
117```
118
119In order to fix this issue, you can manually set the `ZED_RC_TOOLKIT_PATH` environment variable to the RC toolkit path. Usually, you can set it to:
120`C:\Program Files (x86)\Windows Kits\10\bin\<SDK_version>\x64`.
121
122See this [issue](https://github.com/zed-industries/zed/issues/18393) for more information.