Hi guys
So I'm working on this project that uses relatively complex source code, and I'm trying to understand why when patching one dependency by using cloned code in the same branch it's causing errors. It logically doesn't add up.
Can someone help me understand whether this is a bug in rust or something wrong I'm doing?
Here's how to reproduce the issue:
Build the project to ensure it works fine:
git clone https://github.com/PureStake/moonbeam/ && cd moonbeam/
cd node/standalone/
cargo build
this builds fine. Great. Now let's patch the "frontier" components:
mkdir temp && cd temp
git clone https://github.com/purestake/frontier && cd frontier
git checkout v0.2-hotfixes # switch to the branch used in Cargo.toml
cd ../../ # go back to Cargo.toml directory
Now add these lines to Cargo.toml (in the one in node/standalone/) to use the patch we cloned above:
[patch."https://github.com/purestake/frontier"]
ethereum = { package = "pallet-ethereum", path = "temp/frontier/frame/ethereum" }
frontier-consensus = { path = "temp/frontier/consensus" }
frontier-rpc = { path = "temp/frontier/rpc" }
frontier-rpc-primitives = { path = "temp/frontier/rpc/primitives" }
Now build with cargo build
, and it builds fine.
However, if you only patch ethereum
, so you use only these lines, and comment out the others:
[patch."https://github.com/purestake/frontier"]
ethereum = { package = "pallet-ethereum", path = "temp/frontier/frame/ethereum" }
Then you run cargo build
, you get build errors!!!!
Notice that this means that we use the given path for ethereum, but the others should be taken from the repo, which practically should be the exact same code because it's the same branch used at the same time... we just cloned and switched to that branch!
How can this be explained? Aren't both using the same branch and the same repository? Why are we getting broken code? Is this a bug in rust where it's taking a different branch or something, or am I doing something wrong?
Thank you in advance, and sorry for the long question.