lock file version 4 requires `-Znext-lockfile-bump`
Problem
I have tried so many time but always fail.
Cargo build act, but anchor build not act
help me seniors
Steps
No response
Possible Solution(s)
No response
Notes
No response
Version
No response
Lockfile v4 has been stable since Rust 1.78. We are making it the default version as of 1.83 nighties unless your MSRV is below 1.78.
I would look into
- If you can bump your Rust version
- Enforce a lower Rust version is used for anyone who generates the lockfile
- Set
package.rust-version, if applicable
It would also help if the version info of the Rust toolchain is provided. The output of cargo -vV should be sufficient.
Can you provide full reproduction steps with only cargo?
@Kelvin-1013 In Cargo.toml, I changed resolver=2 to resolver=3, and then I got the following error:
resolver is for a different meaning than lockfile version
@epage Then what should I update? Could you please guide me?
As this issue is about lockfiles and you are changing the manifest, this is different. It would be good to provide standard details for someone to help you
- Reproduction steps outside of anchor
- What problem you are trying to solve by switching to
workspace.resolver = "3" - What version of Cargo is being used.
This also looks to more be a Cargo support concern than a bug or feature request, so I would recommend posting about this on https://users.rust-lang.org/
The same issue that @Kelvin-1013 encountered for the same process.
I'm getting the same error
Solution in https://github.com/coral-xyz/anchor/issues/3392#issuecomment-2508412018.
Sorry for the disturbance. It would be nice to lock this issue, given the problem is not about this repository.
Modify the version = "4" at the top of the Cargo.lock file to version = "3".
@kaka527 Thanks a lot, it’s all good now!
Modify the version = "4" at the top of the Cargo.lock file to version = "3".
Only solution that worked for me, thanks @kaka527
Modify the version = "4" at the top of the Cargo.lock file to version = "3".
yes. It worked. I don't understand why.
yes, it worked. Many thanks!
Modify the version = "4" at the top of the Cargo.lock file to version = "3".
This worked, thanks!
I am going to close this, as there is no action needed.
See the updated PR description that provides some solutions if you're stuck.
Using RUST_LOG=debug anchor build I could see that it was my solana cli giving the issues
[2025-01-03T09:42:59.141004000Z INFO cargo_build_sbf] spawn: "/Users/xxx/.cache/solana/v1.39/platform-tools/rust/bin/rustc" --version
[2025-01-03T09:42:59.660304000Z INFO cargo_build_sbf] Solana SDK: /Users/xxx/.local/share/solana/install/releases/1.18.4/solana-release/bin/sdk/sbf
[2025-01-03T09:42:59.660565000Z INFO cargo_build_sbf] spawn: "rustup" toolchain list -v
[2025-01-03T09:42:59.677205000Z INFO cargo_build_sbf] spawn: "cargo" +solana build --release --target sbf-solana-solana
error: failed to parse lock file at: /Users/xxx/WebstormProjects/crypto/xxx/Cargo.lock
Caused by:
lock file version 4 requires `-Znext-lockfile-bump`
Running solana-install update fixed it for me
Modify the version = "4" at the top of the Cargo.lock file to version = "3".
Confirmed, worked thank's have a same issues and got stuck an hours ago
@Kelvin-1013 please don't post unrelated cryptocurrency ads here
error: failed to parse lock file at:
Causedby: lock file version 4 requires-Znext-lockfile-bump`
i was getting this berror when cargo build-sbf or anchor build ..:
cargo build-sbf error: failed to parse lock file at: /home/anrchsun/devs/ana-cain/Cargo.lock
but if you all could read carefully the solution was given in error message:
Caused by: lock file version 4 requires -Znext-lockfile-bump
so i ran :slight_smile:
cargo build-sbf -- -Znext-lockfile-bump
and everything worked fine...
Compiling borsh v0.9.3 Compiling anchor-attribute-access-control v0.30.1 Compiling anchor-attribute-account v0.30.1 Compiling anchor-attribute-error v0.30.1 Compiling anchor-attribute-event v0.30.1 Compiling anchor-attribute-constant v0.30.1 Compiling anchor-derive-serde v0.30.1 Compiling anchor-attribute-program v0.30.1 Compiling anchor-derive-accounts v0.30.1 ^[[B Building [=======================> ] 165/169: solana-program, solana-program Compiling anchor-lang v0.30.1 Compiling ana-chain v0.0.0 (/home/anrchsun/devs/ana-cain/program) Finished release [optimized] target(s) in 1m 31s..
Realise with real Eyes... lok when you read!!
Thank you for your help.
I just modify
resolver=4toresolver=3in Cargo.toml and runanchor build, then this issue is resolved.
this solved my issue although i would like to know about the root cause
good, it works, wonderful
Thank you for your help.
I just modify
resolver=4toresolver=3in Cargo.toml and runanchor build, then this issue is resolved.
Sorry for continuing this discussion that is irrelevant to this repo but I wanted to note that the typo in this comment (Cargo.toml should have been Cargo.lock) is a bit misleading. I guess that is the main reason why there are more people following up in this thread. @Kelvin-1013 could you fix it? it would be really helpful for other people following Google to find a solution here.
@Linyxus please read the maintainer's note in the PR description.