cargo icon indicating copy to clipboard operation
cargo copied to clipboard

lock file version 4 requires `-Znext-lockfile-bump`

Open Kelvin-1013 opened this issue 1 year ago • 4 comments

Problem

Image 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

Kelvin-1013 avatar Oct 08 '24 15:10 Kelvin-1013

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

epage avatar Oct 08 '24 15:10 epage

It would also help if the version info of the Rust toolchain is provided. The output of cargo -vV should be sufficient.

weihanglo avatar Oct 08 '24 16:10 weihanglo

Can you provide full reproduction steps with only cargo?

epage avatar Oct 10 '24 13:10 epage

@Kelvin-1013 In Cargo.toml, I changed resolver=2 to resolver=3, and then I got the following error:

Image

palash2397 avatar Nov 26 '24 14:11 palash2397

resolver is for a different meaning than lockfile version

epage avatar Nov 26 '24 15:11 epage

@epage Then what should I update? Could you please guide me?

palash2397 avatar Nov 26 '24 15:11 palash2397

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/

epage avatar Nov 26 '24 16:11 epage

The same issue that @Kelvin-1013 encountered for the same process.Image

palash2397 avatar Nov 26 '24 18:11 palash2397

I'm getting the same error

619 avatar Nov 28 '24 22:11 619

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.

acheroncrypto avatar Nov 29 '24 19:11 acheroncrypto

Modify the version = "4" at the top of the Cargo.lock file to version = "3".

kaka527 avatar Dec 03 '24 13:12 kaka527

@kaka527 Thanks a lot, it’s all good now!

palash2397 avatar Dec 03 '24 14:12 palash2397

Modify the version = "4" at the top of the Cargo.lock file to version = "3".

Only solution that worked for me, thanks @kaka527

soupy0x avatar Dec 12 '24 04:12 soupy0x

Modify the version = "4" at the top of the Cargo.lock file to version = "3".

yes. It worked. I don't understand why.

trantrongw avatar Dec 15 '24 09:12 trantrongw

yes, it worked. Many thanks!

rcolomina avatar Dec 20 '24 22:12 rcolomina

Modify the version = "4" at the top of the Cargo.lock file to version = "3".

This worked, thanks!

g-lightspeed avatar Dec 23 '24 12:12 g-lightspeed

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.

weihanglo avatar Dec 24 '24 16:12 weihanglo

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

MartinGerritsen avatar Jan 03 '25 09:01 MartinGerritsen

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

hryer avatar Jan 14 '25 22:01 hryer

@Kelvin-1013 please don't post unrelated cryptocurrency ads here

weihanglo avatar Jan 18 '25 13:01 weihanglo

error: failed to parse lock file at:

Causedby: lock file version 4 requires-Znext-lockfile-bump`

anarchsun 4m

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!!

AnarchSun avatar Jan 19 '25 06:01 AnarchSun

Thank you for your help.

I just modify resolver=4 to resolver=3 in Cargo.toml and run anchor build, then this issue is resolved.

this solved my issue although i would like to know about the root cause

muhammedsirajudeen avatar Jan 20 '25 06:01 muhammedsirajudeen

good, it works, wonderful

Pioneer220 avatar Jan 21 '25 09:01 Pioneer220

Thank you for your help.

I just modify resolver=4 to resolver=3 in Cargo.toml and run anchor 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 avatar Jan 27 '25 05:01 Linyxus

@Linyxus please read the maintainer's note in the PR description.

weihanglo avatar Jan 27 '25 13:01 weihanglo