root@d51a1db5c2a8:/# ls
bin boot dev etc home lib lib32 lib64 media mnt my_token_swap opt proc root run sbin srv sys tmp usr var
root@d51a1db5c2a8:/# cd my_token_swap/
root@d51a1db5c2a8:/my_token_swap# anchor build
error: package `solana-program v1.18.26` cannot be built because it requires rustc 1.75.0 or newer, while the currently active rustc version is 1.68.0-dev
Either upgrade to rustc 1.75.0 or newer, or use
cargo update -p [email protected] --precise ver
where `ver` is the latest version of `solana-program` supporting rustc 1.68.0-dev
root@d51a1db5c2a8:/my_token_swap# ls
Anchor.toml Cargo.lock Cargo.toml app migrations node_modules package.json programs target tests tsconfig.json yarn.lock
root@d51a1db5c2a8:/my_token_swap# cat Cargo.toml
[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
root@d51a1db5c2a8:/my_token_swap# cp Cargo.toml Cargo.toml.bak
root@d51a1db5c2a8:/my_token_swap# vi Cargo.toml
root@d51a1db5c2a8:/my_token_swap# which rustc
/root/.cargo/bin/rustc
root@d51a1db5c2a8:/my_token_swap# anchor build
[2024-10-30T04:04:42.899468513Z ERROR cargo_build_sbf] Failed to obtain package metadata: `cargo metadata` exited with an error: error: failed to parse manifest at `/my_token_swap/Cargo.toml`
Caused by:
this virtual manifest specifies a `dependencies` section, which is not allowed
root@d51a1db5c2a8:/my_token_swap# cargo metadata
error: failed to parse manifest at `/my_token_swap/Cargo.toml`
Caused by:
this virtual manifest specifies a `dependencies` section, which is not allowed
2 Answers
Solana uses the rust version from the plattform tools which you can find in:
/Users/userName/.cache/solana
If you are using SPL token crate you can see here https://crates.io/crates/spl-token/6.0.0/dependencies that it needs Solana 2.0.0 So i think you need to update your installed solana version:
Be sure to update your Solana toolchain to the appropriate version. If you already have a toolchain installed, you can simply run:
solana-install init 1.18.26
So when you run cargo build-sbf
, it will download the appropriate Solana compiler and use it.