failed to extract foundry config: foundry config error
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
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:
Try adding ".git" to see if it works?
[dependencies]
OpenZeppelin = { git = "https://github.com/OpenZeppelin/openzeppelin-contracts.git", tag = "v4.4.1" }
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:
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" }
urlandtagaren't valid for dependency values, try chaning it toOpenZeppelin = { url = "https://github.com/OpenZeppelin/openzeppelin-contracts.git", version = "v4.4.1" }
error persists
what is your forge --version output?
forge --version
forge 0.2.0 (1197fbe 2024-08-09T00:22:56.262839000Z)
cc @mario-eth possibly related to soldeer
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:
resolved by discussion above