CosmWasm / optimizer

Dockerfile and script to deterministically produce the smallest possible Wasm for your Rust contract
Apache License 2.0
123 stars 60 forks source link

ErrorInner { kind: Custom, line: None, col: 0, message: "missing field `workspace`", key: [] } } #76

Closed anupam-io closed 2 years ago

anupam-io commented 2 years ago

Facing this issue while using rust-optimizer:

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.5
1.58.1-x86_64-unknown-linux-musl (default)
cargo 1.58.0 (f01b232bc 2022-01-19)
Building artifacts in workspace ...
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Error { inner: ErrorInner { kind: Custom, line: None, col: 0, message: "missing field `workspace`", key: [] } }', src/main.rs:35:55
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Any suggestions on how to resolve this?

webmaster128 commented 2 years ago

cosmwasm/workspace-optimizer is for a multi-contract repo and cosmwasm/rust-optimizer needs to be used if you have a simple one contract project. Which repo are you trying to build with the command above?

anupam-io commented 2 years ago

Mine is a multi-contract repo. Very similar to anchor.

webmaster128 commented 2 years ago

You need to execute the command in the monorepo root where you have a Cargo.toml that contains an workspace entry. Also the workspace-optimizer assumes all contracts are a subfolder of contracts/.

anupam-io commented 2 years ago

Thanks. I was running the command on the wrong path. Resolved now.