Fixing Anchor Version Conflicts When Using avm

Fixing Anchor Version Conflicts When Using avm

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:

  1. Remove the old binary
    This is the simplest and most reliable fix. rm ~/.cargo/bin/anchor Since avm manages its own copy, you don’t need the Cargo-installed one anymore.
  2. 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.

Buy Me A Coffee

Published by Eze Sunday Eze

Hi, welcome to my blog. I am Software Engineer and Technical Writer. And in this blog, I focus on sharing my views on the tech and tools I use. If you love my content and wish to stay in the loop, then by all means share this page and bookmark this website.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.