1[⬅ Back to Index](./index.md)
2
3# Building Zed
4
5How to build Zed from source for the first time.
6
7## Process
8
9Expect this to take 30min to an hour! Some of these steps will take quite a while based on your connection speed, and how long your first build will be.
10
111. Install the [GitHub CLI](https://cli.github.com/):
12 - `brew install gh`
131. Clone the `zed` repo
14 - `gh repo clone zed-industries/zed`
151. Install Xcode from the macOS App Store
161. Install [Postgres](https://postgresapp.com)
171. Install rust/rustup
18 - `curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh`
191. Install the wasm toolchain
20 - `rustup target add wasm32-wasi`
211. Generate an GitHub API Key
22 - Go to https://github.com/settings/tokens and Generate new token
23 - GitHub currently provides two kinds of tokens:
24 - Classic Tokens, where only `repo` (Full control of private repositories) OAuth scope has to be selected
25 Unfortunately, unselecting `repo` scope and selecting every its inner scope instead does not allow the token users to read from private repositories
26 - (not applicable) Fine-grained Tokens, at the moment of writing, did not allow any kind of access of non-owned private repos
27 - Keep the token in the browser tab/editor for the next two steps
281. Open Postgres.app
291. From `./path/to/zed/`:
30 - Run:
31 - `GITHUB_TOKEN={yourGithubAPIToken} script/bootstrap`
32 - Replace `{yourGithubAPIToken}` with the API token you generated above.
33 - Consider removing the token (if it's fine for you to crecreate such tokens during occasional migrations) or store this token somewhere safe (like your Zed 1Password vault).
34 - If you get:
35 - ```bash
36 Error: Cannot install in Homebrew on ARM processor in Intel default prefix (/usr/local)!
37 Please create a new installation in /opt/homebrew using one of the
38 "Alternative Installs" from:
39 https://docs.brew.sh/Installation
40 ```
41 - In that case try:
42 - `/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"`
43 - If Homebrew is not in your PATH:
44 - Replace `{username}` with your home folder name (usually your login name)
45 - `echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> /Users/{username}/.zprofile`
46 - `eval "$(/opt/homebrew/bin/brew shellenv)"`
471. To run the Zed app:
48 - If you are working on zed:
49 - `cargo run`
50 - If you are just using the latest version, but not working on zed:
51 - `cargo run --release`
52 - If you need to run the collaboration server locally:
53 - `script/zed-with-local-servers`
54
55## Troubleshooting
56
57### `error: failed to run custom build command for gpui v0.1.0 (/Users/path/to/zed)`
58
59- Try `xcode-select --switch /Applications/Xcode.app/Contents/Developer`
60
61### `xcrun: error: unable to find utility "metal", not a developer tool or in PATH`
62
63### Seeding errors during `script/bootstrap` runs
64
65```
66seeding database...
67thread 'main' panicked at 'failed to deserialize github user from 'https://api.github.com/orgs/zed-industries/teams/staff/members': reqwest::Error { kind: Decode, source: Error("invalid type: map, expected a sequence", line: 1, column: 0) }', crates/collab/src/bin/seed.rs:111:10
68```
69
70Wrong permissions for `GITHUB_TOKEN` token used, the token needs to be able to read from private repos.
71For Classic GitHub Tokens, that required OAuth scope `repo` (seacrh the scope name above for more details)
72
73Same command
74
75`sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer`
76
77### If you experience errors that mention some dependency is using unstable features
78
79Try `cargo clean` and `cargo build`