stellar / stellar-cli

CLI for Soroban contracts.
65 stars 55 forks source link

contract init: incompatible versions of soroban-sdk & soroban-token-sdk #1498

Closed chadoh closed 1 month ago

chadoh commented 1 month ago

What version are you using?

21.2.0

What did you do?

stellar contract init ohno --with-example token
cd ohno
stellar contract build

What did you expect to see?

all contracts build

What did you see instead?

cargo rustc --manifest-path=contracts/hello_world/Cargo.toml --crate-type=cdylib --target=wasm32-unknown-unknown --release
    Finished `release` profile [optimized] target(s) in 0.04s
   Compiling soroban-token-contract v0.0.6 (/Users/chadoh/code/s/jsdk/test/e2e/test-contracts/contracts/token)
error[E0152]: duplicate lang item in crate `soroban_sdk` (which `soroban_token_sdk` depends on): `panic_impl`.
  |
  = note: the lang item is first defined in crate `soroban_sdk` (which `soroban_token_contract` depends on)
  = note: first definition in `soroban_sdk` loaded from /Users/chadoh/code/s/jsdk/test/e2e/test-contracts/target/wasm32-unknown-unknown/release/deps/libsoroban_sdk-6a9b2044ff704ebd.rlib
  = note: second definition in `soroban_sdk` loaded from /Users/chadoh/code/s/jsdk/test/e2e/test-contracts/target/wasm32-unknown-unknown/release/deps/libsoroban_sdk-f4651df86ac6e5de.rlib, /Users/chadoh/code/s/jsdk/test/e2e/test-contracts/target/wasm32-unknown-unknown/release/deps/libsoroban_sdk-f4651df86ac6e5de.rmeta

Is there a workaround?

Downgrade token contract's soroban-token-sdk dependency to match workspace soroban-sdk version.

The examples were updated to use 21.x here:

Now contract init uses an out-of-date Cargo.toml.

I tried updating the root workspace's soroban-sdk version to 21.4.0 and ended up with irresolvable ed25519-dalek dependency resolution 🤔

What should we do?

We could fix this the easy way, updating the Cargo.toml to use the updated soroban-sdk version. I say this is easy in the hopes that I made some dumb mistake with that ed25519-dalek dependency resolution issue 😅

I wonder if it would be better to also add soroban-token-sdk to the root workspace dependencies, so that we can update packages to use soroban-token-sdk = { workspace = true }, in addition to inheriting soroban-sdk from the workspace.

leighmcculloch commented 1 month ago

I tried updating the root workspace's soroban-sdk version to 21.4.0 and ended up with irresolvable ed25519-dalek dependency resolution 🤔

Cargo isn't always able to automatically resolve all dependencies when dependencies get updated. Running cargo update soroban-token-sdk updates the dependencies appropriately and it builds fine.