Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fails to compile with vendored dependencies #3249

Closed
2 tasks
happysalada opened this issue Sep 17, 2022 · 6 comments
Closed
2 tasks

Fails to compile with vendored dependencies #3249

happysalada opened this issue Sep 17, 2022 · 6 comments
Labels
A-releases Area: releases/packaging T-bug Type: bug

Comments

@happysalada
Copy link

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!

@happysalada happysalada added the T-bug Type: bug label Sep 17, 2022
@gakonst gakonst added this to Foundry Sep 17, 2022
@gakonst gakonst moved this to Todo in Foundry Sep 17, 2022
@rkrasiuk rkrasiuk added the A-releases Area: releases/packaging label Sep 17, 2022
@mattsse
Copy link
Member

mattsse commented Sep 17, 2022

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

@happysalada
Copy link
Author

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.

@zerosnacks
Copy link
Member

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

@happysalada
Copy link
Author

I was waiting for a stable release to try again packaging this for nixos. Any release on the horizon by any chance ?

@zerosnacks
Copy link
Member

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 #3895 + #545?

@happysalada
Copy link
Author

Sure go ahead !

@mattsse mattsse closed this as completed Jun 27, 2024
@jenpaff jenpaff moved this from Todo to Completed in Foundry Sep 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-releases Area: releases/packaging T-bug Type: bug
Projects
Archived in project
Development

No branches or pull requests

4 participants