fix(cli): add edition and rust-version to workspace manifest template#4260
Closed
kukaklaudio wants to merge 1 commit intosolana-foundation:masterfrom
Closed
fix(cli): add edition and rust-version to workspace manifest template#4260kukaklaudio wants to merge 1 commit intosolana-foundation:masterfrom
kukaklaudio wants to merge 1 commit intosolana-foundation:masterfrom
Conversation
The workspace Cargo.toml generated by `anchor init` was missing `edition` and `rust-version` keys. While these were set in individual program Cargo.toml files, Cargo's dependency resolver uses the workspace-level settings for MSRV-aware resolution. Without them, edition2024-only crate versions (e.g. base64ct@1.8.0) could be resolved, causing build failures. Add `[workspace.package]` with `edition = "2021"` and `rust-version` set to ANCHOR_MSRV, and update the program template to inherit these via `.workspace = true`. Fixes solana-foundation#4047
|
Someone is attempting to deploy a commit to the Solana Foundation Team on Vercel. A member of the Team first needs to authorize it. |
Collaborator
|
Duplicate of #4048 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #4047 —
anchor initgenerates a workspaceCargo.tomlmissingeditionandrust-version, which can cause build failures when Cargo resolves edition2024-only dependency versions.Problem
The workspace
Cargo.tomltemplate had noeditionorrust-versionkeys. While individual program crates setedition = "2021", Cargo's MSRV-aware dependency resolver uses workspace-level settings. Without them, crates requiring Rust edition 2024 (e.g.base64ct@1.8.0) could be resolved, breaking builds with:Fix
[workspace.package]section withedition = "2021"andrust-versionset toANCHOR_MSRV(currently1.89.0)Cargo.tomltemplate to inherit these viaedition.workspace = trueandrust-version.workspace = trueThis ensures Cargo's resolver respects the MSRV constraint at the workspace level, preventing incompatible crate versions from being resolved.