Anchor has two common installation paths: installing anchor-cli
directly with Cargo, or installing avm
(Anchor Version Manager) and letting it manage your Anchor versions. When both are present, your shell can end up using the wrong one. This often shows up when you install Anchor 0.31.1
with avm
, but anchor --version
still prints 0.30.1
.
Why this happens
When you run a command, your shell looks through the directories listed in your $PATH
and picks the first matching binary. If you previously installed anchor-cli
with Cargo, you’ll have a copy in ~/.cargo/bin
. After installing avm
, you also get anchor
in ~/.avm/bin
. Most shells load ~/.cargo/bin
earlier in the path, so the old binary takes priority.
How to diagnose
Run:
which -a anchor
If you see both paths, the first one is what your shell is using:
/home/user/.cargo/bin/anchor
/home/user/.avm/bin/anchor
Even if you’ve set avm
to use 0.31.1
, the shell may still pick up the outdated cargo
version.
The fix
There are two ways to solve this:
- Remove the old binary
This is the simplest and most reliable fix.rm ~/.cargo/bin/anchor
Sinceavm
manages its own copy, you don’t need the Cargo-installed one anymore. - Reorder your PATH
If you’d rather keep both, make sure.avm/bin
comes before.cargo/bin
in your shell config (.bashrc
or.zshrc
):export PATH="$HOME/.avm/bin:$PATH"
Reload your shell and check again:anchor --version
Confirming it works
Once the conflict is gone, you should consistently see the version managed by avm
:
anchor-cli 0.31.1
Takeaway
If anchor --version
doesn’t match what avm
reports, it’s almost always a path conflict with an older Cargo install. Cleaning up ~/.cargo/bin/anchor
ensures that your environment uses the version you actually selected with avm
.