[Package]: Zed, an extremely fast Rust-based collabrative code editor that utilizes the GPU+CPU and has AI integration
Why is it worth to add this package?
Zed is an extremely fast, open-source code editor built in Rust, that's optimized for performance and stability. It utilizes both the CPU and GPU, making it insanely quicker than VS Code.
One of Zed’s best features is its AI integration. You can use your own local models (eg: from Ollama) or connect to AI services like OpenAI, Anthropic, Google, or GitHub Copilot. This AI integration is a game-changer for editing as zed shows code diffs(from the AI) directly in the editor, letting you approve or reject changes without the hassle of copy-pasting. Additionally, Zed is currently offering free unlimited access to Claude Sonnet 3.5 (with a 200k token context window) thanks to a partnership with Anthropic.
Zed also shines in collaboration. Its built-in "Rooms" feature makes real-time editing, voice chatting, and code sharing super easy without needing extra extensions. It’s a great tool for teams working together, keeping things simple for collaborative projects. It has a ton more features that are showcased in the home page url
Home page URL
https://zed.dev/
Source code URL
https://github.com/zed-industries/zed
Packaging policy acknowledgement
-
[X] The project is actively developed.
-
[X] The project has existing packages and is "well known".
-
[X] Licensed under an open source license.
-
[X] Not available through a language package manager: pip, npm, cpan, cargo, etc.
-
[X] Not taking up too much disk space (< 100MiB per architecture, exceptions can be made)
-
[X] Not duplicating the functionality of existing packages.
-
[X] Not serving hacking, malware, phishing, spamming, spying, ddos functionality.
-
[X] I certify that I have read Termux Packaging Policy and understand that my request will be denied if it is found lacking.
Additional information
Tried to build using instructions from here https://github.com/zed-industries/zed/blob/main/docs/src/development/linux.md
What I tried(on native termux running on my aarch64 device)
git clone https://github.com/zed-industries/zed.git
cd zed
cargo run
Got this error
error: could not compile `cranelift-codegen` (lib)
Caused by:
process didn't exit successfully: `rustc --crate-name cranelift_codegen --edition=2021 /data/data/com.termux/files/home/.cargo/registry/src/index.crates.io-6f17d22bba15001f/cranelift-codegen-0.108.1/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --diagnostic-width=135 --crate-type lib --emit=dep-info,metadata,link -C opt-level=3 -C embed-bitcode=no -C codegen-units=16 -C debuginfo=1 -C split-debuginfo=unpacked --warn=unused_import_braces --warn=unused_extern_crates --warn=unstable_features --warn=trivial_numeric_casts '--allow=clippy::all' -C debug-assertions=on --cfg 'feature="gimli"' --cfg 'feature="host-arch"' --cfg 'feature="std"' --cfg 'feature="trace-log"' --cfg 'feature="unwind"' --check-cfg 'cfg(docsrs)' --check-cfg 'cfg(feature, values("all-arch", "anyhow", "arm64", "capstone", "core", "default", "disas", "enable-serde", "gimli", "host-arch", "incremental-cache", "isle-errors", "isle-in-source-tree", "postcard", "riscv64", "s390x", "serde", "serde_derive", "sha2", "souper-harvest", "souper-ir", "std", "timing", "trace-log", "unwind", "x86"))' -C metadata=fc3341d7b4642bcb -C extra-filename=-fc3341d7b4642bcb --out-dir /data/data/com.termux/files/home/src/zed/target/debug/deps -L dependency=/data/data/com.termux/files/home/src/zed/target/debug/deps --extern bumpalo=/data/data/com.termux/files/home/src/zed/target/debug/deps/libbumpalo-517d31079c3613a9.rmeta --extern cranelift_bforest=/data/data/com.termux/files/home/src/zed/target/debug/deps/libcranelift_bforest-dad22fee75aabd5a.rmeta --extern cranelift_codegen_shared=/data/data/com.termux/files/home/src/zed/target/debug/deps/libcranelift_codegen_shared-65a2b5af969d12f0.rmeta --extern cranelift_control=/data/data/com.termux/files/home/src/zed/target/debug/deps/libcranelift_control-1d343ad485ebfc58.rmeta --extern cranelift_entity=/data/data/com.termux/files/home/src/zed/target/debug/deps/libcranelift_entity-1f20fd38a8fbb17d.rmeta --extern gimli=/data/data/com.termux/files/home/src/zed/target/debug/deps/libgimli-ccdbdb3418384650.rmeta --extern hashbrown=/data/data/com.termux/files/home/src/zed/target/debug/deps/libhashbrown-42dce89809bec3c5.rmeta --extern log=/data/data/com.termux/files/home/src/zed/target/debug/deps/liblog-ed64794818536102.rmeta --extern regalloc2=/data/data/com.termux/files/home/src/zed/target/debug/deps/libregalloc2-5148abc94001315b.rmeta --extern rustc_hash=/data/data/com.termux/files/home/src/zed/target/debug/deps/librustc_hash-0ef09fc6cb64304d.rmeta --extern smallvec=/data/data/com.termux/files/home/src/zed/target/debug/deps/libsmallvec-5a9ecabd518eac8f.rmeta --extern target_lexicon=/data/data/com.termux/files/home/src/zed/target/debug/deps/libtarget_lexicon-d9dda9d0f746cf51.rmeta --cap-lints allow -C symbol-mangling-version=v0 --cfg tokio_unstable --cfg 'feature="arm64"'` (signal: 11, SIGSEGV: invalid memory reference)
warning: build failed, waiting for other jobs to finish...
did you install all dependencies first?
https://github.com/zed-industries/zed/blob/main/docs/src/development/linux.md#dependencies
did you install all dependencies first?
https://github.com/zed-industries/zed/blob/main/docs/src/development/linux.md#dependencies
well, since rustup isn't available in termux(I think), what I did was run was pkg upgrade rust and cargo update
Then for the dependencies, yeah, I installed the equivalent through manually searching using "pkg search" then "pkg install"
Some packages weren't available for termux though g++, libasound2-dev, libfontconfig-dev to name a few
I tried to help fix this but, to me this looks very difficult and I was not able to progress very much.
Part of the problem is a crash in rustc from the Termux rust package when it is compiling a specific folder of Rust code. Note that I believe the problem is with the build of rustc not with the wasmtime project code, but I tried building several variants of the rust package and all of them reproduced the same crash. I assume finding the exact line of Rust code that is compiled during the crash could help find what exactly to change within the build of the Rust compiler, but that might not be the case.
The crash in rustc can be reproduced with these commands, which don't do very much except install all dependencies that would be required for Zed if it worked, and show the specific code folder within the dependency tree of Zed that is being compiled every time the crash happens.
pkg install x11-repo
pkg install xfce termux-x11-nightly build-essential git rust fontconfig libwayland libxkbcommon openssl zstd vulkan-headers libgit2 gettext elfutils sqlite
git clone --recursive https://github.com/bytecodealliance/wasmtime.git
cd wasmtime/cranelift/codegen/
cargo build
- reproducible on both aarch64 and amd64 with Termux, but not reproducible on either aarch64 or amd64 with GNU/Linux. this suggests a root cause related to something in the Termux packages or in the bionic libc backend of Rust (
rust-std-aarch64-linux-android)
From the reproduction steps that looks unrelated to Zed. I assume it uses cranelift in some capacity?
We do have a wasmtime package, see if that helps.
From the reproduction steps that looks unrelated to Zed. I assume it uses cranelift in some capacity?
We do have a
wasmtimepackage, see if that helps.
Thanks for the suggestion, however, using pkg install wasmtime and trying again did not change the result. What I did try just now is pulling changes into/cloning a new copy of the Zed repository, and something has changed there, since, now, the error from cd zed && cargo build -j1 is not showing cranelift-codegen for me anymore, now it's this
error[E0432]: unresolved import `crate::current_platform`
--> crates/gpui/src/app.rs:31:5
|
31 | current_platform, hash, init_app_menus, Action, ActionRegistry,...
| ^^^^^^^^^^^^^^^^ no `current_platform` in the root
For more information about this error, try `rustc --explain E0432`.
error: could not compile `gpui` (lib) due to 1 previous error
and I did try using a command like this
find . -type f -exec sed -i 's/target_os = "linux"/target_os = "android"/g' {} \;
and then compiling, but that eventually produced this:
Compiling wayland-cursor v0.31.5
error[E0432]: unresolved import `rustix::shm`
--> /data/data/com.termux/files/home/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wayland-cursor-0.31.5/src/lib.rs:62:13
|
62 | use rustix::shm::{shm_open, shm_unlink, ShmOFlags};
| ^^^ could not find `shm` in `rustix`
|
note: found an item that was configured out
--> /data/data/com.termux/files/home/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rustix-0.38.35/src/lib.rs:266:9
|
266 | pub mod shm;
| ^^^
note: the item is gated here
--> /data/data/com.termux/files/home/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rustix-0.38.35/src/lib.rs:257:1
|
257 | / #[cfg(not(any(
258 | | windows,
259 | | target_os = "android",
260 | | target_os = "espidf",
261 | | target_os = "vita",
262 | | target_os = "wasi"
263 | | )))]
| |____^
For more information about this error, try `rustc --explain E0432`.
error: could not compile `wayland-cursor` (lib) due to 1 previous error
And when I compile it in a way that involves deleting that line target_os = "android", there are errors in the portion of the code that is normally disabled on android by that condition:
error[E0425]: cannot find function `shm_open` in module `c`
--> /data/data/com.termux/files/home/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rustix-0.38.35/src/backend/libc/shm/syscalls.rs:20:30
|
20 | unsafe { ret_owned_fd(c::shm_open(c_str(name), bitflags_bits!(oflags), mode)) }
It looks directly analogous to an error that I have observed you fixing in the past in C programs, but unfortunately I do not know how to fix that error in Rust programs yet and I will continue to search for a way to do that
Termux recently updated Rust and it means buildsystem uses newer version of compiler. You can try to build it again to check if it still fails.
259 | | target_os = "android",
You can patch this line out to allow using shm here. You can see how to patch crates in x11/alacritty build recipe.
259 | | target_os = "android",You can patch this line out to allow using shm here. You can see how to patch crates in
x11/alacrittybuild recipe.
I apparently wrote those patches but I sure as hell can't find the specific one you're talking about. Would you mind linking it in your reply above?
I meant build.sh file, it applies diff files to crates.
Yeah I've been up for 17 hours, and have been working on #21850 for the last 2. My brain is not braining very brainily right now.