foundry
foundry copied to clipboard
Fails to compile with vendored dependencies
Component
Other (please describe)
Have you ensured that all of these are up to date?
- [ ] Foundry
- [ ] Foundryup
What version of Foundry are you on?
latest master
What command(s) is the bug in?
cargo build
Operating System
macOS (Intel)
Describe the bug
using cargo vendor
to vendor dependencies, the project fails to compile with errors like
error[E0433]: failed to resolve: use of undeclared crate or module `ethers`
--> /Users/raphael/dev/foundry/vendor/ethers-contract/src/multicall/multicall_contract.rs:903:9
|
903 | ethers_contract :: EthAbiCodec,
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not found in `ethers::core::abi`
|
= note: this error originates in the derive macro `ethers_contract::EthAbiCodec` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider importing one of these items
|
9 | use crate::multicall::Token;
|
9 | use ethers_core::abi::Token;
|
help: if you import `Token`, refer to it directly
|
903 - ethers_contract :: EthAbiCodec,
903 + ethers_contract :: EthAbiCodec,
|
it's quite easy to reproduce. Use cargo vendor
then inside the .cargo/config.toml
file just add the following
[source.crates-io]
replace-with = "vendored-sources"
[source."https://github.com/bluealloy/revm"]
git = "https://github.com/bluealloy/revm"
replace-with = "vendored-sources"
[source."https://github.com/gakonst/ethers-rs"]
git = "https://github.com/gakonst/ethers-rs"
replace-with = "vendored-sources"
[source."https://github.com/roynalnaruto/svm-rs"]
git = "https://github.com/roynalnaruto/svm-rs"
replace-with = "vendored-sources"
[source.vendored-sources]
directory = "vendor"
Context: supporting vendored dependencies would enable forge to be added to nixos
. Rust compilation on nixos can only be done through vendored dependencies.
I understand that this might not be a priority, no worries! Thanks again for making great software!
oh this looks like an issue with how the ethers_core
vs ethers
path is determined in ethers derive macros here
I guess the manifest dir is something different when running cargo vendor
?
https://github.com/gakonst/ethers-rs/blob/master/ethers-core/src/macros/ethers_crate.rs#L51
vendor creates a vendor
directory with all the dependencies.
Judging by the logic of the link you posted, it seems that the CARGO_MANIFEST_DIR env var is not set when using cargo vendor.
The "ethers-contract" crate fails to compile, because the cargo.toml file dependencies doesn't contain "ethers"
[dependencies]
ethers-providers = { version = "^0.17.0", path = "../ethers-providers", default-features = false }
ethers-core = { version = "^0.17.0", path = "../ethers-core", default-features = false }
ethers-contract-abigen = { version = "^0.17.0", path = "ethers-contract-abigen", default-features = false, optional = true }
ethers-contract-derive = { version = "^0.17.0", path = "ethers-contract-derive", optional = true }
ethers-derive-eip712 = { version = "^0.17.0", path = "../ethers-core/ethers-derive-eip712", optional = true }
Adding it there however generates a cyclic dependency. hmmm I'm not sure how to solve this one.
it looks like the macro shouldn't return
return ("ethers::core", "ethers::contract", "ethers::providers")
but not sure what it should return.
Hi @happysalada, would be great if you could re-run this to see if this is still valid considering Ethers has been replaced by Alloy
cargo vendor
runs without issue on my end now
I was waiting for a stable release to try again packaging this for nixos. Any release on the horizon by any chance ?
I was waiting for a stable release to try again packaging this for nixos. Any release on the horizon by any chance ?
Makes sense - hopefully within the next few months. Would it be OK if I close this ticket in favor of https://github.com/foundry-rs/foundry/issues/3895 + https://github.com/foundry-rs/foundry/issues/545?
Sure go ahead !