zed/0.188.3 package update
📊 Build Failed: Resource Limit Exceeded
error: failed to download
hex v0.4.3Caused by: Out of memory
Build Details
| Category | Details |
|---|---|
| Build System | Cargo (Rust) |
| Failure Point | cargo dependency download during build |
Root Cause Analysis 🔍
The build environment ran out of available memory while attempting to download Rust dependencies. This is a resource limitation in the build infrastructure rather than a problem with the package itself.
🔍 Build failure fix suggestions
Found similar build failures that have been fixed in the past and analyzed them to suggest a fix:
Suggested Changes
File: package:zed.yaml
- modify at line 12 (resources section) Original:
memory: 64Gi
Replacement:
memory: 96Gi
Content:
Increase the memory allocation from 64Gi to 96Gi
- modify at line 42 (pipeline section) Original:
- runs: |
cargo fetch --locked
Replacement:
- runs: |
CARGO_NET_RETRY=5 RUSTUP_MAX_RETRIES=10 cargo fetch --locked
Content:
Add retry parameters to cargo fetch command
- add at line after the cargo fetch line (pipeline section) Replacement:
# Set lower parallelism to reduce memory usage
export CARGO_BUILD_JOBS=4
Content:
Add memory optimization flags for Cargo
Click to expand fix analysis
Analysis
The build failure shows a "Out of memory" error while trying to download Rust dependencies with Cargo. The error specifically occurs when downloading the hex v0.4.3 dependency. While there are no similar fixed build failures provided for direct comparison, this is a clear resource limitation issue during the build process. The build environment is running out of memory during the dependency download phase, which is a common issue with large Rust projects like Zed that have extensive dependencies.
Looking at the Melange YAML file, the current memory allocation is 64Gi, which seems substantial but may still be insufficient for this specific build, especially given that Zed is a complex editor with many dependencies and features as indicated in the changelog.
Click to expand fix explanation
Explanation
The suggested changes address the "Out of memory" error during the Rust dependency download phase in several complementary ways:
-
Increasing the memory allocation: The primary change increases the memory allocation from 64Gi to 96Gi. This is the most direct solution to an out-of-memory error. The Zed editor is a complex application with many dependencies (as seen in the changelog with features like SSH support, language servers, AI capabilities, etc.), which can require substantial memory during dependency resolution and compilation.
-
Adding retry parameters to cargo: The
CARGO_NET_RETRY=5 RUSTUP_MAX_RETRIES=10environment variables instruct Cargo and Rustup to retry failed operations (like downloads) multiple times before giving up. This can help overcome transient network or resource issues that might cause a download to fail the first time. -
Limiting build parallelism: By setting
CARGO_BUILD_JOBS=4, we're restricting the number of parallel compilation jobs that Cargo will run. While this may slightly increase build time, it significantly reduces memory usage because fewer compilation processes are running simultaneously. This is particularly important for large Rust projects like Zed where parallel compilation can quickly consume available memory.
These changes together should provide enough memory for the build process while also optimizing how that memory is used during the dependency download and build phases.
Click to expand alternative approaches
Alternative Approaches
- Instead of increasing memory, we could split the build into stages with intermediate checkpoints to reduce peak memory usage. This would involve modifying the pipeline to first fetch dependencies, then build each component separately.
- Another approach would be to use a custom Cargo config file (.cargo/config.toml) with specific memory-saving settings for the build environment, such as limiting the number of codegen units and optimization levels.
- If memory constraints are strict, consider implementing a more aggressive staged build approach that compiles only essential components first, then gradually adds optional features.
- Use the 'sparse' protocol for cargo by adding CARGO_REGISTRIES_CRATES_IO_PROTOCOL=sparse to environment variables, which may be more memory efficient for dependency resolution.
Was this comment helpful? Please use 👍 or 👎 reactions on this comment.
Seems this stems from a bug in Cargo 1.86, as 1.87 doesn't have that issue but typically ships with Rust, of which we're waiting on the next version of. I'll see what I can do in the mean time...
Did some further digging and it seems you're really not supposed to update Cargo outside of updating Rust, and since a bunch of other config tweaks / env vars had no affect on the out of memory error, I would say we're blocked until our newer Rust build lands. Should make this a simple rerun CI and merge after that. I don't really think there's value in trying to hack in a workaround through Rustup at this time.
superseded by https://github.com/wolfi-dev/os/pull/54745