1

I am trying to compile all contracts on the repo root. When running I get an error:

docker run --rm -v "$(pwd)":/code \
  --mount type=volume,source="$(basename "$(pwd)")_cache",target=/code/target \
  --mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \
  cosmwasm/workspace-optimizer:0.12.4
"contracts/cw20-base", "contracts/cw20-ics20", "contracts/cw3-fixed-multisig", "contracts/cw3-flex-multisig", "contracts/cw4-group", "contracts/cw4-stake"]
Building "contracts/cw1-subkeys" ...
 Downloading crates ...
error: failed to download `pkcs8 v0.8.0`

Caused by:
  unable to get packages from source

Caused by:
  failed to parse manifest at `/usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/pkcs8-0.8.0/Cargo.toml`

Caused by:
  feature `edition2021` is required

  The package requires the Cargo feature called `edition2021`, but that feature is not stabilized in this version of Cargo (1.55.0 (32da73ab1 2021-08-23)).
  Consider trying a newer version of Cargo (this may require the nightly release).
  See https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#edition-2021 for more information about the status of this feature.

I tired to run this:

cargo fix --edition

as explained in the edition guide and also this:

rustup default nightly && rustup update

found in similar issues, but still no luck with it.

Current cargo version (but same result with stable one):

cargo 1.63.0-nightly (a4c1cd0eb 2022-05-18)

Any idea or direction on what to try to compile those contracts?

kmdreko
  • 42,554
  • 6
  • 57
  • 106
Arcayne
  • 1,186
  • 1
  • 15
  • 35
  • 1
    The Rust version in the Docker image is older than the version installed on your system. Try bumping the Docker image version: change `cosmwasm/workspace-optimizer:0.12.4` to `cosmwasm/workspace-optimizer:0.12.6` – smitop May 25 '22 at 13:47
  • @Smitop I would gladly mark you comment as the answer, I will research to understand better, but that worked well, I was able to compile the contracts and generate the artifacts – Arcayne May 25 '22 at 14:50
  • I posted it as an answer so you can accept it. – smitop May 25 '22 at 15:11

1 Answers1

1

The Rust compiler in your Docker version is separate from the version on your system, and the version in the image isn't new enough to support the 2021 edition. You can fix this by using a newer version of the Docker image that has a newer Rust compiler:

docker run --rm -v "$(pwd)":/code \
  --mount type=volume,source="$(basename "$(pwd)")_cache",target=/code/target \
  --mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \
  cosmwasm/workspace-optimizer:0.12.6
smitop
  • 4,770
  • 2
  • 20
  • 53