foundry icon indicating copy to clipboard operation
foundry copied to clipboard

failed to extract foundry config: foundry config error

Open Godtide opened this issue 1 year ago • 8 comments

I need help fixing the error below, after adding [dependencies] OpenZeppelin = { git = "https://github.com/OpenZeppelin/openzeppelin-contracts", tag = "v4.4.1" } to the foundry.toml file and running forge build. I get the error
The application panicked (crashed). Message: failed to extract foundry config: foundry config error: data did not match any variant of untagged enum SoldeerDependencyValue for setting dependencies.OpenZeppelin

Location: crates/config/src/lib.rs:559

Screenshot 2024-08-10 at 15 15 00

before adding the dependency I got the error Compiler run failed: Error (6275): Source "lib/ajna-core/lib/openzeppelin-contracts/contracts/token/ERC20/extensions/IERC20Permit.sol" not found: Screenshot 2024-08-10 at 15 26 42

Godtide avatar Aug 10 '24 14:08 Godtide

Try adding ".git" to see if it works?

[dependencies]
OpenZeppelin = { git = "https://github.com/OpenZeppelin/openzeppelin-contracts.git", tag = "v4.4.1" }

Tiamyang avatar Aug 10 '24 14:08 Tiamyang

Try adding ".git" to see if it works?

[dependencies]
OpenZeppelin = { git = "https://github.com/OpenZeppelin/openzeppelin-contracts.git", tag = "v4.4.1" }

It still returns the error The application panicked (crashed). Message: failed to extract foundry config:

Godtide avatar Aug 10 '24 15:08 Godtide

url and tag aren't valid for dependency values, try chaning it to OpenZeppelin = { url = "https://github.com/OpenZeppelin/openzeppelin-contracts.git", version = "v4.4.1" }

klkvr avatar Aug 10 '24 16:08 klkvr

url and tag aren't valid for dependency values, try chaning it to OpenZeppelin = { url = "https://github.com/OpenZeppelin/openzeppelin-contracts.git", version = "v4.4.1" }

error persists

Godtide avatar Aug 10 '24 17:08 Godtide

what is your forge --version output?

klkvr avatar Aug 10 '24 17:08 klkvr

forge --version

forge 0.2.0 (1197fbe 2024-08-09T00:22:56.262839000Z)

Godtide avatar Aug 10 '24 17:08 Godtide

cc @mario-eth possibly related to soldeer

zerosnacks avatar Aug 13 '24 20:08 zerosnacks

hey. as far as i understand you want to install 4.4.1 the easiest way to install it is to go to the website and just go to the version 4.4.1 and install it https://soldeer.xyz/project/@openzeppelin-contracts e.g.

forge soldeer install @openzeppelin-contracts~4.4.1

This will automatically add the openzeppelin into [dependencies] so you don't have to specify it manually.

If you want to use git instead of the repository version, for now we do not support tags, we support only commits so in your case:

forge soldeer install openzeppelin~4.4.1 https://github.com/OpenZeppelin/openzeppelin-contracts.git 6bd6b76d1156e20e45d1016f355d154141c7e5b9

The 6bd6b76d1156e20e45d1016f355d154141c7e5b9 commit represents the last commit of v4.4.1.

Personally i would go with the first option as it's simpler and faster.

After installation, you have to deal with the remappings: inside remappings.txt you will see that a new entry for your installed version was added. that maps a path that you can use inside the solidity file to a path where the dependency is present.

Compiler run failed: Error (6275): Source "lib/ajna-core/lib/openzeppelin-contracts/contracts/token/ERC20/extensions/IERC20Permit.sol" not found:

In your case, i see you use remappings in foundry.toml. For that to work you have to map

remappings = ["@openzeppelin/=dependencies/@op...."]    <== here should be the path to the installed openzeppelin version inside the dependencies directory

Because you use Soldeer, lib directory is not a valid directory for the dependencies, lib is used only by the legacy git submodules way of installing the dependencies, that's why you get the error: Compiler run failed: Error (6275): Source "lib/ajna-core/lib/openzeppelin-contracts/contracts/token/ERC20/extensions/IERC20Permit.sol" not found:

mario-eth avatar Aug 14 '24 06:08 mario-eth

resolved by discussion above

jenpaff avatar Sep 24 '24 13:09 jenpaff