local-collaboration.md

  1# Local Collaboration
  2
  3First, make sure you've installed Zed's backend dependencies for your platform:
  4
  5- [macOS](./macos.md#backend-dependencies)
  6- [Linux](./linux.md#backend-dependencies)
  7- [Windows](./windows.md#backend-dependencies)
  8
  9Note that `collab` can be compiled only with MSVC toolchain on Windows
 10
 11## Database setup
 12
 13Before you can run the `collab` server locally, you'll need to set up a `zed` Postgres database.
 14
 15### On macOS and Linux
 16
 17```sh
 18script/bootstrap
 19```
 20
 21This script will set up the `zed` Postgres database, and populate it with some users. It requires internet access, because it fetches some users from the GitHub API.
 22
 23The script will seed the database with various content defined by:
 24
 25```sh
 26cat crates/collab/seed.default.json
 27```
 28
 29To use a different set of admin users, you can create your own version of that json file and export the `SEED_PATH` environment variable. Note that the usernames listed in the admins list currently must correspond to valid Github users.
 30
 31```json
 32{
 33  "admins": ["admin1", "admin2"],
 34  "channels": ["zed"]
 35}
 36```
 37
 38### On Windows
 39
 40```powershell
 41.\script\bootstrap.ps1
 42```
 43
 44## Testing collaborative features locally
 45
 46### On macOS and Linux
 47
 48Ensure that Postgres is configured and running, then run Zed's collaboration server and the `livekit` dev server:
 49
 50```sh
 51foreman start
 52# OR
 53docker compose up
 54```
 55
 56Alternatively, if you're not testing voice and screenshare, you can just run `collab`, and not the `livekit` dev server:
 57
 58```sh
 59cargo run -p collab -- serve all
 60```
 61
 62In a new terminal, run two or more instances of Zed.
 63
 64```sh
 65script/zed-local -3
 66```
 67
 68This script starts one to four instances of Zed, depending on the `-2`, `-3` or `-4` flags. Each instance will be connected to the local `collab` server, signed in as a different user from `.admins.json` or `.admins.default.json`.
 69
 70### On Windows
 71
 72Since `foreman` is not available on Windows, you can run the following commands in separate terminals:
 73
 74```powershell
 75cargo run --package=collab -- serve all
 76```
 77
 78If you have added the `livekit-server` binary to your `PATH`, you can run:
 79
 80```powershell
 81livekit-server --dev
 82```
 83
 84Otherwise,
 85
 86```powershell
 87.\path\to\livekit-serve.exe --dev
 88```
 89
 90In a new terminal, run two or more instances of Zed.
 91
 92```powershell
 93node .\script\zed-local -2
 94```
 95
 96Note that this requires `node.exe` to be in your `PATH`.
 97
 98## Running a local collab server
 99
100If you want to run your own version of the zed collaboration service, you can, but note that this is still under development, and there is no good support for authentication nor extensions.
101
102Configuration is done through environment variables. By default it will read the configuration from [`.env.toml`](https://github.com/zed-industries/zed/blob/main/crates/collab/.env.toml) and you should use that as a guide for setting this up.
103
104By default Zed assumes that the DATABASE_URL is a Postgres database, but you can make it use Sqlite by compiling with `--features sqlite` and using a sqlite DATABASE_URL with `?mode=rwc`.
105
106To authenticate you must first configure the server by creating a seed.json file that contains at a minimum your github handle. This will be used to create the user on demand.
107
108```json
109{
110  "admins": ["nathansobo"]
111}
112```
113
114By default the collab server will seed the database when first creating it, but if you want to add more users you can explicitly reseed them with `SEED_PATH=./seed.json cargo run -p collab seed`
115
116Then when running the zed client you must specify two environment variables, `ZED_ADMIN_API_TOKEN` (which should match the value of `API_TOKEN` in .env.toml) and `ZED_IMPERSONATE` (which should match one of the users in your seed.json)