setup.mdx

 1export const description = 'Get your machine set up for the first time'
 2
 3# Setup
 4
 5## Getting Zed to build
 6
 7Expect 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.
 8
 91. Install the [GitHub CLI](https://cli.github.com/):
10   - `brew install gh`
112. Clone the `zed` repo
12   - `gh repo clone zed-industries/zed`
133. Install Xcode from the macOS App Store
144. Install [Postgres](https://postgresapp.com)
155. Install rust/rustup
16   - `curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh`
176. Install the wasm toolchain
18   - `rustup target add wasm32-wasi`
197. Generate an GitHub API Key
20   - Go to https://github.com/settings/tokens and Generate new token
21   - GitHub currently provides two kinds of tokens:
22     - Classic Tokens, where only `repo` (Full control of private repositories) OAuth scope has to be selected
23       Unfortunately, unselecting `repo` scope and selecting every its inner scope instead does not allow the token users to read from private repositories
24     - (not applicable) Fine-grained Tokens, at the moment of writing, did not allow any kind of access of non-owned private repos
25   - Keep the token in the browser tab/editor for the next two steps
268. Open Postgres.app
279. From `./path/to/zed/`:
28   - Run:
29     - `GITHUB_TOKEN={yourGithubAPIToken} script/bootstrap`
30     - Replace `{yourGithubAPIToken}` with the API token you generated above.
31   - 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).
32   - If you get:
33     - ```bash
34       Error: Cannot install in Homebrew on ARM processor in Intel default prefix (/usr/local)!
35       Please create a new installation in /opt/homebrew using one of the
36       "Alternative Installs" from:
37       https://docs.brew.sh/Installation
38       ```
39     - In that case try:
40       - `/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"`
41   - If Homebrew is not in your PATH:
42     - Replace `{username}` with your home folder name (usually your login name)
43     - `echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> /Users/{username}/.zprofile`
44     - `eval "$(/opt/homebrew/bin/brew shellenv)"`
4510. To run the Zed app:
46    - If you are working on zed:
47      - `cargo run`
48    - If you are just using the latest version, but not working on zed:
49      - `cargo run --release`
50    - If you need to run the collaboration server locally:
51      - `script/zed-with-local-servers`
52
53## Troubleshooting
54
55### `error: failed to run custom build command for gpui v0.1.0 (/Users/path/to/zed)`
56
57- Try `xcode-select --switch /Applications/Xcode.app/Contents/Developer`
58
59### `xcrun: error: unable to find utility "metal", not a developer tool or in PATH`
60
61### Seeding errors during `script/bootstrap` runs
62
63```
64seeding database...
65thread '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
66```
67
68Wrong permissions for `GITHUB_TOKEN` token used, the token needs to be able to read from private repos.
69For Classic GitHub Tokens, that required OAuth scope `repo` (seacrh the scope name above for more details)
70
71Same command
72
73`sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer`
74
75### If you experience errors that mention some dependency is using unstable features
76
77Try `cargo clean` and `cargo build`