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)

Most upvoted comments

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:

anchor-cli works only on linux x86-64

— Reply to this email directly, view it on GitHub https://github.com/project-serum/anchor/issues/925#issuecomment-1111390280, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABHLFUU45XYKWGTLZV3BPZDVHGHR3ANCNFSM5GU36EEQ . You are receiving this because you commented.Message ID: @.***>

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.

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.

Problem moved from 0.18.0 vs 0.17.0 to 0.18.1 vs 0.18.0 smile

$ npx anchor --version
Package binary version is not correct. Expected "anchor-cli 0.18.1", found "anchor-cli 0.18.0".
Trying globally installed anchor.
Failed to get version of global binary: Error: spawnSync undefined/anchor ENOENT

Second time’s a charm. I didn’t realize the Cargo.toml version had to be set properly when publishing the npm package.