Skip to content
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

lock file version 4 requires -Znext-lockfile-bump #14655

Closed
Kelvin-1013 opened this issue Oct 8, 2024 · 23 comments
Closed

lock file version 4 requires -Znext-lockfile-bump #14655

Kelvin-1013 opened this issue Oct 8, 2024 · 23 comments
Labels
C-bug Category: bug S-needs-info Status: Needs more info, such as a reproduction or more background for a feature request.

Comments

@Kelvin-1013
Copy link

Kelvin-1013 commented Oct 8, 2024

Maintainer's note:

Lockfile v4 has been stabilized since Rust 1.78.0 (#12852), and become the default version when generating/updating Cargo.lock (#14595) since Rust 1.83.0.

The cause you're hitting this hard may be because: The tool you're using called to an older cargo either directly (via cargo executable), or indirectly (depending on cargo as a library). However some other parts of your build system called to a newer cargo that generates a lockfile version 4.

Here are solutions (in order of preference):

  • Help maintainers of the tool you use to support the latest Cargo, either bumping cargo version to 0.84.0+, or wrapping the cargo binary from Rust toolchain 1.83.0+.
  • Setting package.rust-version to a value older than 1.83 if you haven't prepared to support newer toolchains. For example,
    # Cargo.toml
    [package]
    name = "foo"
    rust-version = "1.82" # or any version older than 1.83
    This works because starting from Rust 1.78.0, Cargo respects package.rust-version when generating lockfiles (#12861).
  • Manually edit the lockfile version version = "4" at the top to version = "3".

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 Kelvin-1013 added C-bug Category: bug S-triage Status: This issue is waiting on initial triage. labels Oct 8, 2024
@epage
Copy link
Contributor

epage commented Oct 8, 2024

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

@weihanglo
Copy link
Member

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

@Kelvin-1013
Copy link
Author

Thank you for your response.
Image

Image

`[workspace]
members = [
"programs/*"
]
resolver = "2"

[profile.release]
overflow-checks = true
lto = "fat"
codegen-units = 1
[profile.release.build-override]
opt-level = 3
incremental = false
codegen-units = 1
`

Image

I provide this info, give me advice, seniors

@epage
Copy link
Contributor

epage commented Oct 10, 2024

Can you provide full reproduction steps with only cargo?

@weihanglo weihanglo added S-needs-info Status: Needs more info, such as a reproduction or more background for a feature request. and removed S-triage Status: This issue is waiting on initial triage. labels Oct 10, 2024
@Kelvin-1013
Copy link
Author

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.

jmou added a commit to jmou/redlib that referenced this issue Nov 21, 2024
@palash2397
Copy link

palash2397 commented Nov 26, 2024

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

Image

@epage
Copy link
Contributor

epage commented Nov 26, 2024

resolver is for a different meaning than lockfile version

@palash2397
Copy link

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

@epage
Copy link
Contributor

epage commented Nov 26, 2024

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/

@palash2397
Copy link

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

@619
Copy link

619 commented Nov 28, 2024

I'm getting the same error

@acheroncrypto
Copy link

Solution in coral-xyz/anchor#3392 (comment).

Sorry for the disturbance. It would be nice to lock this issue, given the problem is not about this repository.

@kaka527
Copy link

kaka527 commented Dec 3, 2024

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

@palash2397
Copy link

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

@soupy0x
Copy link

soupy0x commented Dec 12, 2024

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

Only solution that worked for me, thanks @kaka527

@trantrongw
Copy link

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

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

@rcolomina
Copy link

yes, it worked. Many thanks!

r-tamura added a commit to r-tamura/saba that referenced this issue Dec 22, 2024
Cargo.lockのバージョンがcargo 1.78以降4になったが、今回利用するnightlyは1.77だったので対応していなかった(?)
rust-lang/cargo#14655 (comment)
@g-lightspeed
Copy link

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

This worked, thanks!

@Kelvin-1013 Kelvin-1013 reopened this Dec 24, 2024
@weihanglo
Copy link
Member

weihanglo commented Dec 24, 2024

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.

@MartinGerritsen

This comment has been minimized.

@hryer

This comment has been minimized.

@Kelvin-1013

This comment has been minimized.

@weihanglo

This comment has been minimized.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: bug S-needs-info Status: Needs more info, such as a reproduction or more background for a feature request.
Projects
None yet
Development

No branches or pull requests