coral-xyz / anchor

⚓ Solana Sealevel Framework
https://anchor-lang.com
Apache License 2.0
3.36k stars 1.25k forks source link

Install Anchor fails under Windows #2979

Closed Burning-Tiger closed 1 month ago

Burning-Tiger commented 1 month ago

Hi all,

I am getting this error when trying to install Anchor:

    C:\Users\tiger>avm use latest
    Version 0.30.0 is not installed, no current version.
    Error: You need to run 'avm install 0.30.0' to install it before using it.

    C:\Users\tiger>avm install 0.30.0
        Updating git repository `https://github.com/coral-xyz/anchor`
    warning: skipping duplicate package `docs` found at `C:\Users\tiger\.cargo\git\checkouts\anchor-50c4b9c8b5e0501f\852fcc7\tests\idl\programs\docs`
    warning: skipping duplicate package `external` found at `C:\Users\tiger\.cargo\git\checkouts\anchor-50c4b9c8b5e0501f\852fcc7\tests\idl\programs\external`
    warning: skipping duplicate package `relations-derivation` found at `C:\Users\tiger\.cargo\git\checkouts\anchor-50c4b9c8b5e0501f\852fcc7\tests\relations-derivation\programs\relations-derivation`
    warning: skipping duplicate package `swap` found at `C:\Users\tiger\.cargo\git\checkouts\anchor-50c4b9c8b5e0501f\852fcc7\tests\swap\programs\swap`
    warning: skipping duplicate package `shared` found at `C:\Users\tiger\.cargo\git\checkouts\anchor-50c4b9c8b5e0501f\852fcc7\tests\typescript\programs\shared`
    warning: skipping duplicate package `shared` found at `C:\Users\tiger\.cargo\git\checkouts\anchor-50c4b9c8b5e0501f\852fcc7\tests\zero-copy\programs\shared`
         Ignored package `anchor-cli v0.30.0 (https://github.com/coral-xyz/anchor?tag=v0.30.0#852fcc77)` is already installed, use --force to override
    Error: The system cannot find the file specified. (os error 2)

How can I get this working?

Burning-Tiger commented 1 month ago

This trick did not worked for me : https://github.com/coral-xyz/anchor/issues/1952

Burning-Tiger commented 1 month ago

From https://www.anchor-lang.com/docs/installation This worked : Build from source for other operating systems without avm We can also use Cargo to install the CLI directly. Make sure that the --tag argument uses the version you want (the version here is just an example).

  cargo install --git https://github.com/coral-xyz/anchor --tag v0.30.0 anchor-cli --locked
Burning-Tiger commented 1 month ago

For anyone on my steps trying to get Solana working on Windows, they might want to read this link. Some people came to this conclusion :

  First I came to the conclusion that 'anchor build' wasn't working on a windows environment so you have yo use WSL (windows system for Linux).

https://superuser.com/questions/1761050/anchor-build-error-cargo-metadata-os-error-123