I have a simple parent folder and multiple contracts inside it in a simple structure as follows:


I add a root Cargo.toml file under contracts and with the following content:

members = [contract1, contract2]

If I call cargo contract build inside contract1 and contract2 it will work with no issues. If I call cargo build inside the root folder contracts, this will also work. However this is not what we want becuase it's not creating the ink contract bundles. If I call cargo contract build inside the root folder, it would complain:

ERROR: Cannot infer the root project id

These contracts are independent and building them together is just for the sake of having a simple github workflow without the need to know which contracts we will maintain under the contracts folder at the github workflow level. Is this issue known? How can I fix it?


1 Answer 1


This is currently a limitation of cargo contract and generally speaking currently there is no solution for what is asked. If cargo contract needs to be called in a folder other than where Cargo.toml is located in then the solution is to specify the manifest path explicitly. For example:

cargo contract build --manifest-path contracts/contract1/Cargo.toml
cargo contract build --manifest-path contracts/contract2/Cargo.toml

However for running the unit tests, there is no need to use cargo contract and if there is a root Cargo.toml file under contracts with the content as in the question, then the tests for both of the contracts can be run by simply calling cargo test under the contracts directory.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.