-
Notifications
You must be signed in to change notification settings - Fork 1
fix: support for anchor 0.32.1 #31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
WalkthroughThis PR introduces a feature-gated abstraction layer for Pubkey types. When the "anchor" feature is enabled, the SDK uses Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: ASSERTIVE Plan: Pro 📒 Files selected for processing (2)
🧰 Additional context used🧬 Code graph analysis (1)sdk/src/lib.rs (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
🔇 Additional comments (2)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (1)
sdk/Cargo.toml(1 hunks)
🧰 Additional context used
🪛 GitHub Actions: Run Tests
sdk/Cargo.toml
[error] 1-1: Cargo workspace manifest parse error: feature 'anchor' includes 'anchor-lang', but 'anchor-lang' is not an optional dependency. A non-optional dependency of the same name is defined; consider adding 'optional = true' to its definition.
|
|
||
| [features] | ||
| default = [] | ||
| anchor = ["anchor-lang"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
Critical: Resolve Cargo manifest conflict between feature gate and dependency requirement.
The feature definition on line 16 references anchor-lang, but anchor-lang on line 19 is defined as a required (non-optional) dependency. Cargo requires that feature gates reference only optional dependencies, causing the pipeline to fail with a manifest parse error.
Resolve this by choosing one of the following approaches:
Option 1: Keep anchor-lang as an optional dependency (if the feature gating is intentional)
Restore optional = true to the dependency:
-anchor-lang = { workspace = true }
+anchor-lang = { workspace = true, optional = true }Option 2: Remove the feature gate (if anchor-lang is truly required)
Remove the feature definition since anchor-lang is now unconditionally required:
[features]
default = []
-anchor = ["anchor-lang"]Verify which approach aligns with the PR's intent to support Anchor 0.32.1.
Also applies to: 19-19
I'll verify the actual state of the Cargo.toml file and the configuration.
🏁 Script executed:
#!/bin/bash
# Check the actual state of sdk/Cargo.toml, especially lines around 16-19
cat sdk/Cargo.tomlLength of output: 575
🏁 Script executed:
#!/bin/bash
# Also search for anchor-lang across the file to understand full context
grep -n "anchor" sdk/Cargo.tomlLength of output: 65
🏁 Script executed:
#!/bin/bash
# Check if there are any other references to optional dependencies or features
grep -n -A2 -B2 "\[features\]" sdk/Cargo.tomlLength of output: 80
🏁 Script executed:
#!/bin/bash
# Look for dependencies section
grep -n -A10 "\[dependencies\]" sdk/Cargo.tomlLength of output: 182
---
🌐 Web query:
```web
Cargo feature gates optional dependencies requirement
💡 Result:
Short summary:
-
Mark a dependency optional with
optional = truein Cargo.toml; Cargo will (currently) create an implicit feature with the same name that enables that optional dep. Use that feature in code with#[cfg(feature = "name")]. [1][2] -
To expose an optional dependency explicitly as a feature (or to make feature groups activate a dependency), list the dependency name in a feature entry or use the
dep:syntax: e.g.
[features]
my-feature = ["dep:foo"]
or in older style the implicitfoo = ["dep:foo"]. This is how you gate inclusion of that optional crate. [1][2] -
Cargo also supports
required-featureson targets (binaries/examples/bench/tests) to disable building a target unless features are enabled (useful for feature-gated binaries). See the "required-features" docs. [1][3] -
Note: an RFC removed implicit exposure of optional dependencies as plain features (authors should prefer
dep:...when they intend to expose them). Check the Cargo/features docs or RFC 3491 for current behavior if you need exact, up-to-date semantics. [3]
If you want, tell me your Cargo.toml and I’ll show the exact manifest lines you need.
Sources: Cargo features documentation and RFC. [1] [2] [3]
References:
[1] Cargo Book — Features & Optional dependencies (Rust docs).
[2] Cargo Book — Manifest / features rules (Cargo reference).
[3] RFC 3491 (remove implicit features).
Critical: Resolve Cargo manifest conflict—feature references non-optional dependency.
The feature definition on line 16 references anchor-lang, but anchor-lang on line 19 is not marked as an optional dependency. In Cargo, features can only reference optional dependencies, causing the manifest parse error.
Resolve by choosing one approach:
Option 1: Make anchor-lang optional (if feature gating is intentional)
Add optional = true and use the dep: syntax per current Cargo best practices:
-anchor-lang = { workspace = true }
+anchor-lang = { workspace = true, optional = true }-anchor = ["anchor-lang"]
+anchor = ["dep:anchor-lang"]Option 2: Remove the feature gate (if anchor-lang is truly required)
[features]
default = []
-anchor = ["anchor-lang"]Verify the intent and apply the appropriate fix.
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| anchor = ["anchor-lang"] | |
| anchor-lang = { workspace = true, optional = true } |
| anchor = ["anchor-lang"] | |
| anchor = ["dep:anchor-lang"] |
🤖 Prompt for AI Agents
In sdk/Cargo.toml around line 16, the feature "anchor = [\"anchor-lang\"]"
references a non-optional dependency which causes a manifest error; fix by
either 1) making anchor-lang optional and updating the feature to reference the
dependency via the dep: syntax (set anchor-lang = { version = \"...\", optional
= true } in [dependencies] and feature = [\"dep:anchor-lang\"]) if you intended
feature-gating, or 2) remove the feature reference entirely and keep anchor-lang
as a normal required dependency if it should always be present.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Summary by CodeRabbit