Compare commits

...

7 Commits

Author SHA1 Message Date
Peter Tripp
24d6d5696d zed 0.155.2 2024-10-01 10:18:43 -04:00
Peter Tripp
546837af2d Support More Linux (#18480)
- Add `script/build-docker`
- Add `script/install-cmake`
- Add `script/install-mold`
- Improve `script/linux` 
  - Add missing dependencies: `jq`, `git`, `tar`, `gzip` as required.
  - Add check for mold
  - Fix Redhat 8.x derivatives (RHEL, Centos, Almalinux, Rocky, Oracle, Amazon)
  - Fix perl libs to be Fedora only
  - Install the best `libstdc++` available on apt distros
  - ArchLinux: run `pacman -Syu` to update repos before installing. 
  - Should work on Raspbian (untested) 

This make it possible to test builds on other distros using docker:
```
./script/build-docker amazonlinux:2023
```
2024-10-01 09:51:40 -04:00
Peter Tripp
21f9ac0add ci: Use BuildJet Ubuntu 20.04 runners for better glibc compatibility (#18442)
Use BuildJet Ubuntu 20.04 runners.
- Linux arm64 unchanged (glibc >= 2.35)
- Linux x64 glibc requirement becomes to >= 2.31 (from glibc >= 2.35).

Note: Ubuntu 20.04 repo cmake (3.16.3) is normally too old to build Zed, but `ubuntu-2004` [includes cmake
3.30.3](https://github.com/actions/runner-images/blob/main/images/ubuntu/Ubuntu2004-Readme.md#tools).
2024-10-01 09:51:33 -04:00
Peter Tripp
9ff594e2e9 zed 0.155.1 2024-09-27 12:36:33 -04:00
Peter Tripp
ee75909409 Fix Ollama timeouts broken on Preview (#18449)
Supersedes: https://github.com/zed-industries/zed/pull/18310
See also: https://github.com/zed-industries/zed/issues/18304

This PR targets v0.155.x and is a hotfix for Preview.

Signed-off-by: Vladimir Bulyga <zero@13w.me>
Co-authored-by: Vladimir Bulyga <zero@13w.me>
2024-09-27 12:32:52 -04:00
Conrad Irwin
d0706aa36c Avoid unwrap in file finder (#18374)
Release Notes:

- Fixed a (rare) panic in file finder

---------

Co-authored-by: Kirill Bulatov <kirill@zed.dev>
2024-09-27 10:38:15 +03:00
Joseph T Lyons
b0c264d94a v0.155.x preview 2024-09-25 11:02:25 -04:00
16 changed files with 294 additions and 50 deletions

View File

@@ -271,7 +271,7 @@ jobs:
timeout-minutes: 60
name: Create a Linux bundle
runs-on:
- buildjet-16vcpu-ubuntu-2204
- buildjet-16vcpu-ubuntu-2004
if: ${{ startsWith(github.ref, 'refs/tags/v') || contains(github.event.pull_request.labels.*.name, 'run-bundling') }}
needs: [linux_tests]
env:
@@ -284,7 +284,7 @@ jobs:
clean: false
- name: Install Linux dependencies
run: ./script/linux
run: ./script/linux && ./script/install-mold 2.34.0
- name: Determine version and release channel
if: ${{ startsWith(github.ref, 'refs/tags/v') }}

View File

@@ -100,7 +100,7 @@ jobs:
name: Create a Linux *.tar.gz bundle for x86
if: github.repository_owner == 'zed-industries'
runs-on:
- buildjet-16vcpu-ubuntu-2204
- buildjet-16vcpu-ubuntu-2004
needs: tests
env:
DIGITALOCEAN_SPACES_ACCESS_KEY: ${{ secrets.DIGITALOCEAN_SPACES_ACCESS_KEY }}
@@ -117,7 +117,7 @@ jobs:
run: echo "$HOME/.cargo/bin" >> $GITHUB_PATH
- name: Install Linux dependencies
run: ./script/linux
run: ./script/linux && ./script/install-mold 2.34.0
- name: Limit target directory size
run: script/clear-target-dir-if-larger-than 100

3
Cargo.lock generated
View File

@@ -7523,6 +7523,7 @@ dependencies = [
"anyhow",
"futures 0.3.30",
"http_client",
"isahc",
"schemars",
"serde",
"serde_json",
@@ -14388,7 +14389,7 @@ dependencies = [
[[package]]
name = "zed"
version = "0.155.0"
version = "0.155.2"
dependencies = [
"activity_indicator",
"anyhow",

26
Dockerfile-distros Normal file
View File

@@ -0,0 +1,26 @@
# syntax=docker/dockerfile:1
ARG BASE_IMAGE
FROM ${BASE_IMAGE}
WORKDIR /app
ARG TZ=Etc/UTC \
LANG=C.UTF-8 \
LC_ALL=C.UTF-8 \
DEBIAN_FRONTEND=noninteractive
ENV CARGO_TERM_COLOR=always
COPY script/linux script/
RUN ./script/linux
COPY script/install-mold script/install-cmake script/
RUN ./script/install-mold "2.34.0"
RUN ./script/install-cmake "3.30.4"
COPY . .
# When debugging, make these into individual RUN statements.
# Cleanup to avoid saving big layers we aren't going to use.
RUN . "$HOME/.cargo/env" \
&& cargo fetch \
&& cargo build \
&& cargo run -- --help \
&& cargo clean --quiet

View File

@@ -0,0 +1,2 @@
**/target
**/node_modules

View File

@@ -394,7 +394,7 @@ fn matching_history_items<'a>(
.chars(),
),
};
candidates_paths.insert(Arc::clone(&found_path.project.path), found_path);
candidates_paths.insert(&found_path.project, found_path);
Some((found_path.project.worktree_id, candidate))
})
.fold(
@@ -419,17 +419,21 @@ fn matching_history_items<'a>(
max_results,
)
.into_iter()
.map(|path_match| {
let (_, found_path) = candidates_paths
.remove_entry(&path_match.path)
.expect("candidate info not found");
(
Arc::clone(&path_match.path),
Match::History {
path: found_path.clone(),
panel_match: Some(ProjectPanelOrdMatch(path_match)),
},
)
.filter_map(|path_match| {
candidates_paths
.remove_entry(&ProjectPath {
worktree_id: WorktreeId::from_usize(path_match.worktree_id),
path: Arc::clone(&path_match.path),
})
.map(|(_, found_path)| {
(
Arc::clone(&path_match.path),
Match::History {
path: found_path.clone(),
panel_match: Some(ProjectPanelOrdMatch(path_match)),
},
)
})
}),
);
}

View File

@@ -19,6 +19,7 @@ schemars = ["dep:schemars"]
anyhow.workspace = true
futures.workspace = true
http_client.workspace = true
isahc.workspace = true
schemars = { workspace = true, optional = true }
serde.workspace = true
serde_json.workspace = true

View File

@@ -1,6 +1,7 @@
use anyhow::{anyhow, Context, Result};
use futures::{io::BufReader, stream::BoxStream, AsyncBufReadExt, AsyncReadExt, StreamExt};
use http_client::{http, AsyncBody, HttpClient, Method, Request as HttpRequest};
use isahc::config::Configurable;
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
use serde_json::{value::RawValue, Value};
@@ -262,14 +263,18 @@ pub async fn stream_chat_completion(
client: &dyn HttpClient,
api_url: &str,
request: ChatRequest,
_: Option<Duration>,
low_speed_timeout: Option<Duration>,
) -> Result<BoxStream<'static, Result<ChatResponseDelta>>> {
let uri = format!("{api_url}/api/chat");
let request_builder = http::Request::builder()
let mut request_builder = http::Request::builder()
.method(Method::POST)
.uri(uri)
.header("Content-Type", "application/json");
if let Some(low_speed_timeout) = low_speed_timeout {
request_builder = request_builder.low_speed_timeout(100, low_speed_timeout);
};
let request = request_builder.body(AsyncBody::from(serde_json::to_string(&request)?))?;
let mut response = client.send(request).await?;
if response.status().is_success() {

View File

@@ -2,7 +2,7 @@
description = "The fast, collaborative code editor."
edition = "2021"
name = "zed"
version = "0.155.0"
version = "0.155.2"
publish = false
license = "GPL-3.0-or-later"
authors = ["Zed Team <hi@zed.dev>"]

View File

@@ -1 +1 @@
dev
preview

View File

@@ -35,6 +35,12 @@ Clone down the [Zed repository](https://github.com/zed-industries/zed).
brew install cmake
```
- (Optional) Install `mold` to speed up link times
```sh
brew install mold
```
## Backend Dependencies
If you are developing collaborative features of Zed, you'll need to install the dependencies of zed's `collab` server:

View File

@@ -16,7 +16,7 @@ The Zed installed by the script works best on systems that:
- have a Vulkan compatible GPU available (for example Linux on an M-series macBook)
- have a system-wide glibc (NixOS and Alpine do not by default)
- x86_64 (Intel/AMD): glibc version >= 2.35 (Ubuntu 22 and newer)
- x86_64 (Intel/AMD): glibc version >= 2.29 (Ubuntu 20 and newer)
- aarch64 (ARM): glibc version >= 2.35 (Ubuntu 22 and newer)
Both Nix and Alpine have third-party Zed packages available (though they are currently a few weeks out of date). If you'd like to use our builds they do work if you install a glibc compatibility layer. On NixOS you can try [nix-ld](https://github.com/Mic92/nix-ld), and on Alpine [gcompat](https://wiki.alpinelinux.org/wiki/Running_glibc_programs).
@@ -24,8 +24,8 @@ Both Nix and Alpine have third-party Zed packages available (though they are cur
You will need to build from source for:
- architectures other than 64-bit Intel or 64-bit ARM (for example a 32-bit or RISC-V machine)
- Amazon Linux
- Rocky Linux 9.3
- Redhat Enterprise Linux 8.x, Rocky Linux 8, AlmaLinux 8, Amazon Linux 2 on all architectures
- Redhat Enterprise Linux 9.x, Rocky Linux 9.3, AlmaLinux 8, Amazon Linux 2023 on aarch64 (x86_x64 OK)
## Other ways to install Zed on Linux

25
script/build-docker Executable file
View File

@@ -0,0 +1,25 @@
#!/usr/bin/env bash
# Use a docker BASE_IMAGE to test building Zed.
# e.g: ./script/bundle-docker ubuntu:20.04
#
# Increasing resources available to podman may speed this up:
# podman machine stop
# podman machine set --memory 16384 --cpus 8 --disk-size 200
# podman machine start
set -euo pipefail
BASE_IMAGE=${BASE_IMAGE:-${1:-}}
if [ -z "$BASE_IMAGE" ]; then
echo "Usage: $0 BASE_IMAGE" >&2
exit 1
fi
export DOCKER_BUILDKIT=1
cd "$(dirname "$0")/.."
podman build . \
-f Dockerfile-distros \
-t many \
--build-arg BASE_IMAGE="$BASE_IMAGE"

77
script/install-cmake Executable file
View File

@@ -0,0 +1,77 @@
#!/usr/bin/env bash
#
# This script installs an up-to-date version of CMake.
#
# For MacOS use Homebrew to install the latest version.
#
# For Ubuntu use the official KitWare Apt repository with backports.
# See: https://apt.kitware.com/
#
# For other systems (RHEL 8.x, 9.x, AmazonLinux, SUSE, Fedora, Arch, etc)
# use the official CMake installer script from KitWare.
#
# Note this is similar to how GitHub Actions runners install cmake:
# https://github.com/actions/runner-images/blob/main/images/ubuntu/scripts/build/install-cmake.sh
#
# Upstream: 3.30.4 (2024-09-27)
set -euo pipefail
if [[ "$(uname -s)" == "darwin" ]]; then
brew --version >/dev/null \
|| echo "Error: Homebrew is required to install cmake on MacOS." && exit 1
echo "Installing cmake via Homebrew (can't pin to old versions)."
brew install cmake
exit 0
elif [ "$(uname -s)" != "Linux" ]; then
echo "Error: This script is intended for MacOS/Linux systems only."
exit 1
elif [ -z "${1:-}" ]; then
echo "Usage: $0 [3.30.4]"
exit 1
fi
CMAKE_VERSION="${CMAKE_VERSION:-${1:-3.30.4}}"
if [ "$(whoami)" = root ]; then SUDO=; else SUDO="$(command -v sudo || command -v doas || true)"; fi
if cmake --version | grep -q "$CMAKE_VERSION"; then
echo "CMake $CMAKE_VERSION is already installed."
exit 0
elif [ -e /usr/local/bin/cmake ]; then
echo "Warning: existing cmake found at /usr/local/bin/cmake. Skipping installation."
exit 0
elif [ -e /etc/apt/sources.list.d/kitware.list ]; then
echo "Warning: existing KitWare repository found. Skipping installation."
exit 0
elif [ -e /etc/lsb-release ] && grep -qP 'DISTRIB_ID=Ubuntu' /etc/lsb-release; then
curl -fsSL https://apt.kitware.com/keys/kitware-archive-latest.asc \
| $SUDO gpg --dearmor - \
| $SUDO tee /usr/share/keyrings/kitware-archive-keyring.gpg >/dev/null
echo "deb [signed-by=/usr/share/keyrings/kitware-archive-keyring.gpg] https://apt.kitware.com/ubuntu/ $(lsb_release -cs) main" \
| $SUDO tee /etc/apt/sources.list.d/kitware.list >/dev/null
$SUDO apt-get update
$SUDO apt-get install -y kitware-archive-keyring cmake==$CMAKE_VERSION
else
arch="$(uname -m)"
if [ "$arch" != "x86_64" ] && [ "$arch" != "aarch64" ]; then
echo "Error. Only x86_64 and aarch64 are supported."
exit 1
fi
tempdir=$(mktemp -d)
pushd "$tempdir"
CMAKE_REPO="https://github.com/Kitware/CMake"
CMAKE_INSTALLER="cmake-$CMAKE_VERSION-linux-$arch.sh"
curl -fsSL --output cmake-$CMAKE_VERSION-SHA-256.txt \
"$CMAKE_REPO/releases/download/v$CMAKE_VERSION/cmake-$CMAKE_VERSION-SHA-256.txt"
curl -fsSL --output $CMAKE_INSTALLER \
"$CMAKE_REPO/releases/download/v$CMAKE_VERSION/cmake-$CMAKE_VERSION-linux-$arch.sh"
# workaround for old versions of sha256sum not having --ignore-missing
grep -F "cmake-$CMAKE_VERSION-linux-$arch.sh" "cmake-$CMAKE_VERSION-SHA-256.txt" \
| sha256sum -c \
| grep -qP "^${CMAKE_INSTALLER}: OK"
chmod +x cmake-$CMAKE_VERSION-linux-$arch.sh
$SUDO ./cmake-$CMAKE_VERSION-linux-$arch.sh --prefix=/usr/local --skip-license
popd
rm -rf "$tempdir"
fi

37
script/install-mold Executable file
View File

@@ -0,0 +1,37 @@
#!/usr/bin/env bash
# Install `mold` official binaries from GitHub Releases.
#
# Adapted from the official rui314/setup-mold@v1 action to:
# * use environment variables instead of action inputs
# * remove make-default support
# * use curl instead of wget
# * support doas for sudo
# * support redhat systems
# See: https://github.com/rui314/setup-mold/blob/main/action.yml
set -euo pipefail
MOLD_VERSION="${MOLD_VERSION:-${1:-}}"
if [ "$(uname -s)" != "Linux" ]; then
echo "Error: This script is intended for Linux systems only."
exit 1
elif [ -z "$MOLD_VERSION" ]; then
echo "Usage: $0 2.34.0"
exit 1
elif [ -e /usr/local/bin/mold ]; then
echo "Warning: existing mold found at /usr/local/bin/mold. Skipping installation."
exit 0
fi
if [ "$(whoami)" = root ]; then SUDO=; else SUDO="$(command -v sudo || command -v doas || true)"; fi
MOLD_REPO="${MOLD_REPO:-https://github.com/rui314/mold}"
MOLD_URL="${MOLD_URL:-$MOLD_REPO}/releases/download/v$MOLD_VERSION/mold-$MOLD_VERSION-$(uname -m)-linux.tar.gz"
echo "Downloading from $MOLD_URL"
curl -fsSL --output - "$MOLD_URL" \
| $SUDO tar -C /usr/local --strip-components=1 --no-overwrite-dir -xzf -
# Note this binary depends on the system libatomic.so.1 which is usually
# provided as a dependency of gcc so it should be available on most systems.

View File

@@ -1,15 +1,25 @@
#!/usr/bin/env bash
set -ex
set -xeuo pipefail
# install the wasm toolchain
which rustup > /dev/null 2>&1 || curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
# if root or if sudo/unavailable, define an empty variable
if [ "$(id -u)" -eq 0 ]
then maysudo=''
else maysudo="$(command -v sudo || command -v doas || true)"
fi
# if sudo is not installed, define an empty alias
maysudo=$(command -v sudo || command -v doas || true)
function finalize {
# after packages install (curl, etc), get the rust toolchain
which rustup > /dev/null 2>&1 || curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
# verify the mold situation
if ! command -v mold >/dev/null 2>&1; then
echo "Warning: Mold binaries are unavailable on your system." >&2
echo " Builds will be slower without mold. Try: scripts/install-mold" >&2
fi
echo "Finished installing Linux dependencies with script/linux"
}
# Ubuntu, Debian, etc.
# https://packages.ubuntu.com/
# Ubuntu, Debian, Mint, Kali, Pop!_OS, Raspbian, etc.
apt=$(command -v apt-get || true)
if [[ -n $apt ]]; then
deps=(
@@ -20,55 +30,95 @@ if [[ -n $apt ]]; then
libwayland-dev
libxkbcommon-x11-dev
libssl-dev
libstdc++-12-dev
libzstd-dev
libvulkan1
libgit2-dev
make
cmake
clang
mold
jq
git
curl
gettext-base
elfutils
libsqlite3-dev
)
if (grep -qP 'PRETTY_NAME="(.+24\.04)' /etc/os-release); then
deps+=( mold libstdc++-14-dev )
elif (grep -qP 'PRETTY_NAME="((Debian|Raspbian).+12|.+22\.04)' /etc/os-release); then
deps+=( mold libstdc++-12-dev )
elif (grep -qP 'PRETTY_NAME="((Debian|Raspbian).+11|.+20\.04)' /etc/os-release); then
deps+=( libstdc++-10-dev )
fi
$maysudo "$apt" update
$maysudo "$apt" install -y "${deps[@]}"
finalize
exit 0
fi
# Fedora, CentOS, RHEL, etc.
# https://packages.fedoraproject.org/
# Fedora, CentOS, RHEL, Alma, Amazon 2023, Oracle, etc.
dnf=$(command -v dnf || true)
if [[ -n $dnf ]]; then
# Old Redhat (yum only): Amazon Linux 2, Oracle Linux 7, etc.
yum=$(command -v yum || true)
if [[ -n $dnf ]] || [[ -n $yum ]]; then
pkg_cmd="${dnf:-${yum}}"
deps=(
gcc
g++
clang
cmake
mold
alsa-lib-devel
fontconfig-devel
wayland-devel
libxkbcommon-x11-devel
openssl-devel
libzstd-devel
# Perl dependencies are needed for openssl-sys crate see https://docs.rs/openssl/latest/openssl/
perl-FindBin
perl-IPC-Cmd
perl-File-Compare
perl-File-Copy
vulkan-loader
sqlite-devel
jq
git
tar
)
# libxkbcommon-x11-devel is in the crb repo on RHEL and CentOS, not needed for Fedora
if ! grep -q "Fedora" /etc/redhat-release; then
$maysudo "$dnf" config-manager --set-enabled crb
# perl used for building openssl-sys crate. See: https://docs.rs/openssl/latest/openssl/
if grep -qP '^ID="(fedora)' /etc/os-release; then
deps+=(
perl-FindBin
perl-IPC-Cmd
perl-File-Compare
perl-File-Copy
mold
)
elif grep grep -qP '^ID="(rhel|rocky|alma|centos|ol)' /etc/os-release; then
deps+=( perl-interpreter )
fi
$maysudo "$dnf" install -y "${deps[@]}"
# gcc-c++ is g++ on RHEL8 and 8.x clones
if grep -qP '^ID="(rhel|rocky|alma|centos|ol)' /etc/os-release \
&& grep -qP '^VERSION_ID="8' /etc/os-release; then
deps+=( gcc-c++ )
else
deps+=( g++ )
fi
# libxkbcommon-x11-devel is in a non-default repo on RHEL 8.x/9.x (except on AmazonLinux)
if grep -qP '^VERSION_ID="(8|9)' && grep -qP '^ID="(rhel|rocky|centos|alma|ol)' /etc/os-release; then
$maysudo dnf install -y 'dnf-command(config-manager)'
if grep -qP '^PRETTY_NAME="(AlmaLinux 8|Rocky Linux 8)' /etc/os-release; then
$maysudo dnf config-manager --set-enabled powertools
elif grep -qP '^PRETTY_NAME="((AlmaLinux|Rocky|CentOS Stream) 9|Red Hat.+(8|9))' /etc/os-release; then
$maysudo dnf config-manager --set-enabled crb
elif grep -qP '^PRETTY_NAME="Oracle Linux Server 8' /etc/os-release; then
$maysudo dnf config-manager --set-enabled ol8_codeready_builder
elif grep -qP '^PRETTY_NAME="Oracle Linux Server 9' /etc/os-release; then
$maysudo dnf config-manager --set-enabled ol9_codeready_builder
else
echo "Unexpected distro" && grep 'PRETTY_NAME' /etc/os-release && exit 1
fi
fi
$maysudo $pkg_cmd install -y "${deps[@]}"
finalize
exit 0
fi
@@ -89,10 +139,14 @@ if [[ -n $zyp ]]; then
openssl-devel
libzstd-devel
libvulkan1
mold
sqlite3-devel
jq
git
tar
gzip
)
$maysudo "$zyp" install -y "${deps[@]}"
finalize
exit 0
fi
@@ -115,8 +169,10 @@ if [[ -n $pacman ]]; then
mold
sqlite
jq
git
)
$maysudo "$pacman" -S --needed --noconfirm "${deps[@]}"
$maysudo "$pacman" -Syu --needed --noconfirm "${deps[@]}"
finalize
exit 0
fi
@@ -143,6 +199,7 @@ if [[ -n $xbps ]]; then
sqlite-devel
)
$maysudo "$xbps" -Syu "${deps[@]}"
finalize
exit 0
fi
@@ -152,6 +209,7 @@ emerge=$(command -v emerge || true)
if [[ -n $emerge ]]; then
deps=(
app-arch/zstd
app-misc/jq
dev-libs/openssl
dev-libs/wayland
dev-util/cmake
@@ -164,7 +222,9 @@ if [[ -n $emerge ]]; then
dev-db/sqlite
)
$maysudo "$emerge" -u "${deps[@]}"
finalize
exit 0
fi
echo "Unsupported Linux distribution in script/linux"
exit 1