Loading video player...
PART of the Solana Development series. In this lesson we explain why a Solana Anchor project often has two Cargo.toml files and what each one controls. You will see how the root workspace Cargo.toml differs from the program’s Cargo.toml inside programs/your_program, how dependencies and features are resolved, and how to avoid common version mismatches when building and deploying to devnet. What you will learn: The role of the root workspace Cargo.toml vs the program Cargo.toml How [workspace], members, and workspace.dependencies centralize versions Where to declare anchor-lang, anchor-spl, solana-program, and other crates How features work in programs, including no-entrypoint, cpi, idl-build Why programs usually set [lib] crate-type = ["cdylib","lib"] for Solana How cargo build -p anchor build, and anchor run pick which file to use Tips for keeping Anchor CLI and crate versions in sync Troubleshooting duplicate dependency versions, feature conflicts, and resolver issues Quick mental model: Root Cargo.toml = project manager. Declares the workspace, members, shared dependency versions, build profiles. Program Cargo.toml = app specifics. Declares the program crate metadata, its features, and any program-only dependencies. Example layout you will see in the video: project-root/ Cargo.toml # workspace-level Anchor.toml programs/ my_program/ Cargo.toml # program-level src/lib.rs Common pitfalls and fixes: Mismatched Anchor versions. Pin anchor-lang and anchor-spl in workspace.dependencies so all programs share the same version. Missing crate-type. Ensure program Cargo.toml has [lib] crate-type = ["cdylib","lib"] so it compiles to a Solana shared object. Feature leakage. Keep program features like no-entrypoint only in the program Cargo.toml. Dependency duplication. Use workspace.dependencies to avoid pulling multiple versions of the same crate. Who this is for: Developers learning Solana with Anchor who see multiple Cargo.toml files and want clarity Rust beginners moving from single-crate apps to multi-crate workspaces Teams standardizing versions and build profiles across several on-chain programs Free worksheet prompts included in the video: Workspace checklist for root Cargo.toml Program Cargo.toml template with features and crate-type set Version sync checklist for Anchor CLI and crates Build and run commands cheat sheet for cargo and anchor Action steps after watching: Move shared crate versions into [workspace.dependencies] and remove duplicates from program Cargo.toml files Add crate-type and features to each program Cargo.toml and confirm anchor build succeeds Run cargo tree -e features -p your_program to verify one version per critical crate Align anchor CLI version with anchor-lang and anchor-spl in your workspace Search keywords to help you find this later: Cargo.toml workspace vs package, Solana Anchor Cargo.toml, Rust workspace dependencies, anchor-lang anchor-spl versions, Solana program crate-type cdylib, Rust features no-entrypoint cpi, cargo build workspace, Anchor build devnet, Solana deployment tips. Watch the full series to learn idea validation, Rust basics for Solana, Anchor project structure, building, testing, and deploying on devnet and mainnet. Subscribe to follow each new part and get the worksheets. #rust #solana #anchor #cargo #workspace #blockchaindevelopment #web3 #devnet #rustbeginner #smartcontracts #solanaprogram