coral-xyz / anchor

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

cleint/src/lib.rs PubsubClientError::UnexpectedErrorMessageError #2571

Closed Sam-Berman1 closed 1 year ago

Sam-Berman1 commented 1 year ago

After bypassing the error described here

an avm install latest

returns:

   Compiling anchor-client v0.28.0 (.cargo\git\checkouts\anchor-50c4b9c8b5e0501f\e1afcbf\client)
error[E0599]: no variant or associated item named `UnexpectedMessageError` found for enum `solana_client::nonblocking::pubsub_client::PubsubClientError` in the current scope
   --> client\src\lib.rs:252:77
    |
252 |                     ClientError::SolanaClientPubsubError(PubsubClientError::UnexpectedMessageError(
    |                                                                             ^^^^^^^^^^^^^^^^^^^^^^ variant or associated item not found in `PubsubClientError`
Aursen commented 1 year ago

You need to use versions 1.16 of the Solana crates

acheroncrypto commented 1 year ago

Can you share full logs? This looks like a cache issue because avm uses locked versions for dependencies which should get 1.16.

anchor-client issue with 1.14 is fixed in #2572 but it shouldn't affect avm install latest.

Try installing the latest CLI with:

cargo install --git https://github.com/coral-xyz/anchor anchor-cli --locked --force

Both of the issues might be happening only on Windows(haven't seen anybody else report them), it's recommended to use WSL for Solana development on Windows.

Sam-Berman1 commented 1 year ago

I deleted my .cargo/git/checkouts and started fresh to better understand where this might be a user error.

In order to use cargo install --git https://github.com/coral-xyz/anchor anchor-cli --locked --force I must edit /avm and /cli Cargo.toml file to use tokio 1.28.0

without /avm or /cli edited I receive:

error[E0793]: reference to packed field is unaligned --> .cargo\registry\src\index.crates.io-6f17d22bba15001f\ntapi-0.3.7\src\ntexapi.rs:2807:25 | 2807 | ((read_volatile(&(*USER_SHARED_DATA).u.TickCountQuad)

**with /avm edited and not /cli I receive:**
$ cargo install --git https://github.com/coral-xyz/anchor anchor-cli --locked --force
    Updating git repository `https://github.com/coral-xyz/anchor`
warning: skipping duplicate package `relations-derivation` found at .cargo\git\checkouts\anchor-50c4b9c8b5e0501f\cf057ac\tests\relations-derivation\programs\relations-derivation`
warning: skipping duplicate package `swap` found at `.cargo\git\checkouts\anchor-50c4b9c8b5e0501f\cf057ac\tests\swap\programs\swap`
warning: skipping duplicate package `shared` found at `.cargo\git\checkouts\anchor-50c4b9c8b5e0501f\cf057ac\tests\typescript\programs\shared`
warning: skipping duplicate package `shared` found at `.cargo\git\checkouts\anchor-50c4b9c8b5e0501f\cf057ac\tests\zero-copy\programs\shared`
  Installing anchor-cli v0.28.0 (https://github.com/coral-xyz/anchor#cf057aca)
    Updating crates.io index
error: failed to select a version for `tokio`.
    ... required by package `avm v0.28.0 .cargo\git\checkouts\anchor-50c4b9c8b5e0501f\cf057ac\avm)`
versions that meet the requirements `^1.28.0` are: 1.29.1, 1.29.0, 1.28.2, 1.28.1, 1.28.0

all possible versions conflict with previously selected packages.

  previously selected package `tokio v1.14.1`
    ... which satisfies dependency `tokio = "~1.14.1"` of package `anchor-cli v0.28.0 (.cargo\git\checkouts\anchor-50c4b9c8b5e0501f\cf057ac\cli)`

failed to select a version for `tokio` which could resolve this conflict

This allows me to bypass those errors. Now, I experience the error documented here

error[E0277]: the trait bound `solana_program::pubkey::Pubkey: BorshSerialize` is not satisfied
  --> lang\src\idl.rs:35:10
   |
35 | #[derive(AnchorSerialize, AnchorDeserialize)]
   |          ^^^^^^^^^^^^^^^ the trait `BorshSerialize` is not implemented for `solana_program::pubkey::Pubkey`
   |
   = help: the following other types implement trait `BorshSerialize`:
             &T
             ()
             (T0, T1)
             (T0, T1, T2)
             (T0, T1, T2, T3)
             (T0, T1, T2, T3, T4)
             (T0, T1, T2, T3, T4, T5)
             (T0, T1, T2, T3, T4, T5, T6)
           and 81 others
   = help: see issue #48214
   = note: this error originates in the derive macro `AnchorSerialize` (in Nightly builds, run with -Z macro-backtrace for more info)

cargo update -p solana-zk-token-sdk --precise 1.14.19 cargo update -p borsh@0.10.3 --precise 0.9.3

allows the install to complete. however as @Aursen stated, this looks like it uses downgraded solana-crates.

   Compiling solana-metrics v1.14.19
   Compiling solana-measure v1.14.19
   Compiling solana-zk-token-sdk v1.14.19
   Compiling solana-remote-wallet v1.14.19
   Compiling solana-net-utils v1.14.19
   Compiling solana-config-program v1.14.19
   Compiling solana-clap-utils v1.14.19
   Compiling solana-streamer v1.14.19
   Compiling solana-cli-config v1.14.19
   Compiling spl-token-2022 v0.6.1
   Compiling solana-faucet v1.14.19
   Compiling solana-account-decoder v1.14.19
   Compiling spl-associated-token-account v1.1.3
   Compiling solana-transaction-status v1.14.19
   Compiling solana-client v1.14.19
Replaced package `avm v0.28.0 (https://github.com/coral-xyz/anchor#cf057aca)` with `anchor-cli v0.28.0 (https://github.com/coral-xyz/anchor#cf057aca)` (executable `anchor.exe`)

Now, the avm install latest again results in:

.cargo\registry\src\index.crates.io-6f17d22bba15001f\ntapi-0.3.7\src\ntexapi.rs:2783:52
     |
2783 |         *tick_count.QuadPart_mut() = read_volatile(&(*USER_SHARED_DATA).u.TickCountQuad);
     |                                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

I again re-edit_ avm & cli Cargo.toml to use tokio 1.28.0. (this doesn't feel right) and reissue avm install latest returns

**Compiling solana-client v1.14.20 Compiling anchor-client v0.28.0 (.cargo\git\checkouts\anchor-50c4b9c8b5e0501f\e1afcbf\client) error[E0599]: no variant or associated item named UnexpectedMessageError found for enum solana_client::nonblocking::pubsub_client::PubsubClientError in the current scope --> client\src\lib.rs:252:77 | 252 | ClientError::SolanaClientPubsubError(PubsubClientError::UnexpectedMessageError( | ^^^^^^^^^^^^^^^^^^^^^^ variant or associated item not found in PubsubClientError

Aursen commented 1 year ago

@acheroncrypto fixed it with #2572

Sam-Berman1 commented 1 year ago

Thank you.

acheroncrypto commented 1 year ago

Closing this as it's fixed in #2572.

jeromeballena-dev commented 1 year ago

@Sam-Berman1 is this issue resolved, I'm experiencing the same problem