Skip to content
4 changes: 4 additions & 0 deletions WARP.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ Environment variables:
- `./script/run-clang-format.py -r --extensions 'c,h,cpp,m' ./crates/warpui/src/ ./app/src/` - Format C/C++/Obj-C code
- `find . -name "*.wgsl" -exec wgslfmt --check {} +` - Check WGSL shader formatting

### Prerequisites
- **Node.js 18.14.1+** — Required by the `command-signatures-v2` crate, which compiles a TypeScript helper at build time using yarn.
- **Yarn 4+ via Corepack** — Required by the `command-signatures-v2` build script. Enable via `corepack enable` after installing Node.js; avoid Yarn 1.x from package managers such as Homebrew.

### Platform Setup
- `./script/bootstrap` - Platform-specific setup (calls platform-specific bootstrap scripts)
- `./script/install_cargo_build_deps` - Install Cargo build dependencies
Expand Down
50 changes: 50 additions & 0 deletions script/linux/bootstrap
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,56 @@ set -e
# don't do it (to avoid doing it more than once).
sudo apt update -y

# Check for Node.js and yarn (required by command-signatures-v2 crate).
# The build.rs in that crate compiles a TypeScript helper using yarn,
# which requires Node.js 18.14.1+ and Yarn 4+ via Corepack.
REQUIRED_NODE_VERSION="18.14.1"
if ! command -v node &>/dev/null; then
echo -e "\033[0;31mError: Node.js is not installed.\033[0m"
echo "Node.js $REQUIRED_NODE_VERSION+ is required to build the command-signatures-v2 crate."
echo "Install it via your system package manager, nvm, fnm, or volta:"
echo " https://nodejs.org/en/download"
exit 1
fi

NODE_VERSION="$(node --version | sed 's/^v//')"
if [[ "$(printf '%s\n' "$REQUIRED_NODE_VERSION" "$NODE_VERSION" | sort -V | head -n1)" != "$REQUIRED_NODE_VERSION" ]]; then
echo -e "\033[0;31mError: Node.js $NODE_VERSION is too old.\033[0m"
echo "Node.js $REQUIRED_NODE_VERSION+ is required. Current version: $NODE_VERSION"
echo "Upgrade via your system package manager, nvm, fnm, or volta."
exit 1
fi

if ! command -v yarn &>/dev/null; then
echo -e "\033[0;31mError: yarn is not installed.\033[0m"
echo "yarn is required to build the command-signatures-v2 crate."
echo "Enable it via corepack (ships with Node.js):"
echo " corepack enable"
exit 1
fi

# Verify yarn version is 4+ (Corepack-managed), not 1.x (Homebrew).
# Check from the js crate directory where Corepack reads packageManager.
JS_CRATE_DIR="$PWD/crates/command-signatures-v2/js"
if ! YARN_VERSION="$(cd "$JS_CRATE_DIR" && yarn --version 2>/dev/null)"; then
echo -e "\033[0;31mError: Could not determine yarn version from $JS_CRATE_DIR.\033[0m"
echo "Ensure yarn is installed and Corepack is enabled:"
echo " corepack enable"
exit 1
fi
YARN_MAJOR="$(echo "$YARN_VERSION" | cut -d. -f1)"
if [ "$YARN_MAJOR" -lt 4 ] 2>/dev/null; then
echo -e "\033[0;31mError: yarn $YARN_VERSION detected, but Yarn 4+ is required.\033[0m"
echo "The command-signatures-v2 crate requires Yarn 4 via Corepack."
echo "If you have yarn installed via Homebrew, remove it first:"
echo " brew uninstall yarn"
echo "Then enable Corepack:"
echo " corepack enable"
exit 1
fi

echo "✅ Node.js $(node --version) and yarn $YARN_VERSION detected."

# Install all dependencies needed to build, run, and test Warp.
"$PWD"/script/linux/install_test_deps

Expand Down
64 changes: 64 additions & 0 deletions script/linux/install_build_deps
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,70 @@ else
echo -e "⚠️ ${red}Unknown Linux distribution; necessary build dependencies may not be installed!${reset}"
fi

# Check for Node.js (required by command-signatures-v2 crate).
# The build.rs in that crate compiles a TypeScript helper using yarn,
# which requires Node.js 18.14.1+ and yarn (typically via corepack).
REQUIRED_NODE_VERSION="18.14.1"
if ! command -v node >/dev/null 2>&1; then
echo "Error: Node.js is not installed."
echo "Node.js $REQUIRED_NODE_VERSION+ is required to build the command-signatures-v2 crate."
echo "Install it via: curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash - && sudo apt-get install -y nodejs"
echo " or use a version manager like nvm, fnm, or volta."
exit 1
fi

NODE_VERSION="$(node --version | sed 's/^v//')"
node_major="$(echo "$NODE_VERSION" | cut -d. -f1)"
node_minor="$(echo "$NODE_VERSION" | cut -d. -f2)"
node_patch="$(echo "$NODE_VERSION" | cut -d. -f3)"
req_major="$(echo "$REQUIRED_NODE_VERSION" | cut -d. -f1)"
req_minor="$(echo "$REQUIRED_NODE_VERSION" | cut -d. -f2)"
req_patch="$(echo "$REQUIRED_NODE_VERSION" | cut -d. -f3)"

if [ "$node_major" -lt "$req_major" ] || \
{ [ "$node_major" -eq "$req_major" ] && [ "$node_minor" -lt "$req_minor" ]; } || \
{ [ "$node_major" -eq "$req_major" ] && [ "$node_minor" -eq "$req_minor" ] && [ "$node_patch" -lt "$req_patch" ]; }; then
echo "Error: Node.js $NODE_VERSION is too old."
echo "Node.js $REQUIRED_NODE_VERSION+ is required."
echo "Upgrade via your system package manager or version manager."
exit 1
fi

# Check for yarn (required by command-signatures-v2 crate).
# The crate uses Yarn 4 via Corepack, not Yarn 1 from system packages.
# yarn is typically enabled via `corepack enable` after installing Node.js.
if ! command -v yarn >/dev/null 2>&1; then
echo "Error: yarn is not installed."
echo "yarn is required to build the command-signatures-v2 crate."
echo "Enable it via corepack (ships with Node.js):"
echo " corepack enable"
exit 1
fi

# Verify yarn version is 4.x (Corepack-managed), not 1.x (system package).
# Check from the js crate directory where Corepack reads packageManager.
# Wrap in `if !` so that a Corepack/yarn failure shows guidance instead of
# exiting silently under `set -e`.
JS_CRATE_DIR="$PWD/crates/command-signatures-v2/js"
if ! YARN_VERSION="$(cd "$JS_CRATE_DIR" && yarn --version 2>/dev/null)"; then
echo "Error: Could not determine yarn version from $JS_CRATE_DIR."
echo "Ensure yarn is installed and Corepack is enabled:"
echo " corepack enable"
exit 1
fi
YARN_MAJOR="$(echo "$YARN_VERSION" | cut -d. -f1)"
if [ "$YARN_MAJOR" -lt 4 ] 2>/dev/null; then
echo "Error: yarn $YARN_VERSION detected, but Yarn 4+ is required."
echo "The command-signatures-v2 crate requires Yarn 4 via Corepack."
echo "If you have yarn installed via a system package, remove it first:"
echo " sudo apt-get remove yarn # or equivalent for your distro"
echo "Then enable Corepack:"
echo " corepack enable"
exit 1
fi

echo "✅ Node.js $(node --version) and yarn $YARN_VERSION detected."

# Install Rust.
"$PWD"/script/install_rust

Expand Down
64 changes: 64 additions & 0 deletions script/macos/bootstrap
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,70 @@ if ! command -v cargo; then
exit 1
fi

# Check for Node.js (required by command-signatures-v2 crate).
# The build.rs in that crate compiles a TypeScript helper using yarn,
# which requires Node.js 18.14.1+ and yarn (typically via corepack).
REQUIRED_NODE_VERSION="18.14.1"
if ! command -v node >/dev/null 2>&1; then
echo "Error: Node.js is not installed."
echo "Node.js $REQUIRED_NODE_VERSION+ is required to build the command-signatures-v2 crate."
echo "Install it via: brew install node"
echo " or use a version manager like nvm, fnm, or volta."
exit 1
fi

NODE_VERSION="$(node --version | sed 's/^v//')"
# Compare semantic versions properly (not lexicographically).
# Split into major.minor.patch and compare each component.
node_major="$(echo "$NODE_VERSION" | cut -d. -f1)"
node_minor="$(echo "$NODE_VERSION" | cut -d. -f2)"
node_patch="$(echo "$NODE_VERSION" | cut -d. -f3)"
req_major="$(echo "$REQUIRED_NODE_VERSION" | cut -d. -f1)"
req_minor="$(echo "$REQUIRED_NODE_VERSION" | cut -d. -f2)"
req_patch="$(echo "$REQUIRED_NODE_VERSION" | cut -d. -f3)"

if [ "$node_major" -lt "$req_major" ] || \
{ [ "$node_major" -eq "$req_major" ] && [ "$node_minor" -lt "$req_minor" ]; } || \
{ [ "$node_major" -eq "$req_major" ] && [ "$node_minor" -eq "$req_minor" ] && [ "$node_patch" -lt "$req_patch" ]; }; then
echo "Error: Node.js $NODE_VERSION is too old."
echo "Node.js $REQUIRED_NODE_VERSION+ is required."
echo "Upgrade via: brew upgrade node"
exit 1
fi

# Check for yarn (required by command-signatures-v2 crate).
# The crate uses Yarn 4 via Corepack, not Yarn 1 from Homebrew.
# yarn is typically enabled via `corepack enable` after installing Node.js.
if ! command -v yarn >/dev/null 2>&1; then
echo "Error: yarn is not installed."
echo "yarn is required to build the command-signatures-v2 crate."
echo "Enable it via corepack (ships with Node.js):"
echo " corepack enable"
exit 1
fi

# Verify yarn version is 4.x (Corepack-managed), not 1.x (Homebrew).
# Check from the js crate directory where Corepack reads packageManager.
JS_CRATE_DIR="$PWD/crates/command-signatures-v2/js"
if ! YARN_VERSION="$(cd "$JS_CRATE_DIR" && yarn --version 2>/dev/null)"; then
echo "Error: Could not determine yarn version from $JS_CRATE_DIR."
echo "Ensure yarn is installed and Corepack is enabled:"
echo " corepack enable"
exit 1
fi
YARN_MAJOR="$(echo "$YARN_VERSION" | cut -d. -f1)"
if [ "$YARN_MAJOR" -lt 4 ] 2>/dev/null; then
echo "Error: yarn $YARN_VERSION detected, but Yarn 4+ is required."
echo "The command-signatures-v2 crate requires Yarn 4 via Corepack."
echo "If you have yarn installed via Homebrew, remove it first:"
echo " brew uninstall yarn"
echo "Then enable Corepack:"
echo " corepack enable"
exit 1
fi

echo "✅ Node.js $(node --version) and yarn $YARN_VERSION detected."

# Install various binaries through cargo.
"$PWD"/script/install_cargo_test_deps
"$PWD"/script/install_cargo_release_deps
Expand Down