Solana: Anchor build says “cannot build because it requires rustc 1.75.0 or later” I have rustc 1.82.0 installed
Anchor validation issue: Rustc version mismatch in Docker environment
Summary
Recently, users reported a problem when trying to verify their Anchor accounts using the anchor verify
command. The problem is that this command requires access to a working Rust compiler, specifically version 1.75.0 or later. However, the user discovered that he had an earlier version of Rustc installed on his system, which caused the program to fail.
Problem
The anchor verify' Anchor command is used to confirm and verify the authenticity of the received Anchor address. To use this command, you must ensure that a working Rust compiler is available. The problem arises when the anchor-verify program is requested to be built using the built-in Rust compiler installed on the system.
Code
The code foranchor verify'' looks like this:
rust
use anchor_lang::prelude::*;
[program]
pub fn anchor_verify(
_owner: Id,
accounts: Accounts<'_>,
) -> Result<()> {
// ...
}
anchor_verify
This code snippet demonstrates the basic structure of a Rust function. It defines an Anchor program with a single
function that takes several parameters.
anchor verify
User's decisionOne user reported that he encountered this problem when trying to compile and run the
command:
bash
anchor verify 3MRKmmRZ6Fm4tvEEjBZcuGG7nxWVSYCJd83WzmAGqm8J
When he ran this command, he encountered an error message indicating that his Rust compiler was incompatible with the required version.
Solution
To solve this problem, the user installed a newer version of Rust (1.82.0) on his system, which allows him to compile and run the
anchor verify' program without facing compatibility problems:
bash
rustc 1.82.0 -o anchor-verify --edition=2018
``
Having installed an earlier version of Rustc (version 1.75.0), the user was unable to compile and run theanchor-verify' program, which caused the provided command to fail.
Conclusion
This issue highlights the importance of having access to a working Rust compiler when requesting Anchor account verification using the anchor verify
command. Users can resolve this issue by upgrading their version of Rust to a compatible installation (eg 1.82.0).