anchor: npm: Invalid anchor version
npm package 0.18.0 have invalid anchor binary 😞
$ npm ls @project-serum/anchor-cli
solana-protocol@0.2.0 /home/kirill/projects/x-project
└── @project-serum/anchor-cli@0.18.0
$ npx anchor --version
Package binary version is not correct. Expected "anchor-cli 0.18.0", found "anchor-cli 0.17.0".
Trying globally installed anchor.
Failed to get version of global binary: Error: spawnSync undefined/anchor ENOENT
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 20 (9 by maintainers)
If you tried installing Anchor with npm on a non-x86_64 Linux and it failed, then you installed from source successfully but got the errors above -> Try uninstalling the npm version with:
npm uninstall -g @project-serum/anchor-cli
Then try using the Anchor CLI. Should work without conflict.Need to use WSL
On Wed, Apr 27, 2022 at 12:21 PM Kirill Fomichev @.***> wrote:
Using
npm uninstall -g @project-serum/anchor-cli
with the caveat, instead of using npm to install the CLI, I installed and used the AVM( aka Anchor Version Manager) with ‘cargo install --git https://github.com/project-serum/anchor avm --locked --force’ then ran ‘avm install latest’ then ‘avm use latest’ then restarted the terminal, which worked for me on Ubuntu WSL / Windows Subsystem Linux, . Also had to set the path variable in linux.Second time’s a charm. I didn’t realize the Cargo.toml version had to be set properly when publishing the npm package.