macOS 用 Zed の構築

リポジトリ

Zed リポジトリ を複製します。

依存関係

  • Rust をインストールします。
  • macOS App Store または Apple Developer Web サイトから Xcode をインストールします。この操作には開発者アカウントが必要であることに注意してください。

インストール後に XCode を起動し、MacOS コンポーネント(既定のオプション)をインストールします。

  • Xcode コマンドラインツール をインストールします。

    xcode-select --install
    
  • Xcode コマンドラインツールが、新しくインストールされた Xcode のコピーを使用していることを確認します。

    sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
    
  • Rust wasm ツールチェーンをインストールします。

    rustup target add wasm32-wasi
    

バックエンド依存関係

Zed のコラボレーション機能を開発している場合は、zed の collab サーバーの依存関係をインストールする必要があります。

  • Postgres をインストールします。

  • LivekitForeman をインストールします。

    brew install livekit foreman
    

または、Docker がインストールされている場合は、Docker Compose を使用して collab 依存関係をすべて立ち上げることができます。

docker compose up -d

ソースからの Zed の構築

依存関係をインストールすると、Cargo を使用して Zed を構築できます。

デバッグビルドの場合

cargo run

リリースビルドの場合

cargo run --release

テストを実行する場合

cargo test --workspace

トラブルシューティング

メタルシェーダーのコンパイルエラー

error: failed to run custom build command for gpui v0.1.0 (/Users/path/to/zed)`**

xcrun: error: unable to find utility "metal", not a developer tool or in PATH

sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer を試してください。

依存関係が不安定な機能を使用しているという Cargo エラー

cargo cleancargo build を試してみてください。

エラー: 'dispatch/dispatch.h' ファイルが見つかりません

次のようなエラーが発生した場合は

src/platform/mac/dispatch.h:1:10: fatal error: 'dispatch/dispatch.h' file not found

Caused by:
  process didn't exit successfully

  --- stdout
  cargo:rustc-link-lib=framework=System
  cargo:rerun-if-changed=src/platform/mac/dispatch.h
  cargo:rerun-if-env-changed=TARGET
  cargo:rerun-if-env-changed=BINDGEN_EXTRA_CLANG_ARGS_aarch64-apple-darwin
  cargo:rerun-if-env-changed=BINDGEN_EXTRA_CLANG_ARGS_aarch64_apple_darwin
  cargo:rerun-if-env-changed=BINDGEN_EXTRA_CLANG_ARGS

このファイルは Xcode の一部です。Xcode コマンドラインツールがインストールされており、正しいパスが設定されていることを確認してください。

xcode-select --install
sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer

さらに、BINDGEN_EXTRA_CLANG_ARGS 環境変数を設定します。

export BINDGEN_EXTRA_CLANG_ARGS="--sysroot=$(xcrun --show-sdk-path)"

その後、プロジェクトをクリーンアップして再構築します。

cargo clean
cargo run