zed/crates/extension_host
Maciej Piasecki 6bd235c1a3
extension_host: Fix cross-device extension installs (#56437)
This fixes extension installation when Zed's cache directory and data
directory are on different filesystems or mount points. On my Linux
system, `~/.cache` is a separate btrfs subvolume so it can be excluded
from system snapshots, while `~/.local/share` is on the main home
subvolume. Installing extensions failed because extension archives were
unpacked under `paths::temp_dir()` and then renamed into the installed
extensions directory.

The error showed up as:
```text
2026-05-11T17:08:57+02:00 INFO  [extension_host] installing extension dockerfile latest version
2026-05-11T17:08:58+02:00 ERROR [crates/extension_host/src/extension_host.rs:842] Invalid cross-device link (os error 18)
```

Linux rename(2) returns EXDEV (os error 18) across filesystem
boundaries. This is the same class of issue addressed for settings
writes in #8437 and later generalized in
2b3e453d2f. The regression was introduced
by #54355, which made extension updates safer by unpacking into a
temporary directory before renaming into place.

This change creates the temporary unpack directory inside the installed
extensions directory instead. That keeps the final rename on the same
filesystem as the destination while preserving the existing
direct-unpack fallback if creating the temporary directory fails. A
possible alternative would be to create a dedicated temporary install
directory under `extensions/`, alongside `extensions/installed/`. I
chose, however, to keep the temporary directory directly beside the
final destination because that matches the destination-local temp-file
approach used in the earlier fixes referenced above.

Self-Review Checklist:

- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content is consistent with the [UI/UX
checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
- [ ] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

No separate issue. The change is small and includes the reproduction
context here. I did not add a regression test because the failure
depends on cache and data directories being on different
filesystems/subvolumes; this was verified manually by reproducing EXDEV
when installing extensions with `~/.cache` on a separate btrfs
subvolume, then confirming the patch fixes extension installation.

Release Notes:

- Fixed installing extensions when Zed's cache and data directories are
on different filesystems.
2026-05-11 17:58:17 +00:00
..
benches Revert "Revert scheduler update (#46659)" (#46671) 2026-01-14 07:19:13 +00:00
src extension_host: Fix cross-device extension installs (#56437) 2026-05-11 17:58:17 +00:00
build.rs
Cargo.toml theme: Split out theme_settings crate (#52569) 2026-03-27 14:41:25 +01:00
LICENSE-GPL