-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
feat: allow single file remappings #6706
Comments
could you please provide a repro for this? |
@tash-2s I wonder if this is related to the recent path changes? |
I'll look into this. @arthurneuron Did the same setup and command work in previous versions of forge? (Is this an issue that occurred after updating forge?) It would be really helpful if you could provide a detailed reproduction of the error. |
I believe this is the reproduction of the issue: $ mkdir issues6706 && cd issues6706
$ mkdir src my-lib
$ cat << EOF > src/A.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.23;
import "@my-lib/B.sol";
contract A is B {}
EOF
$ cat << EOF > my-lib/B.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.23;
contract B {}
EOF
$ cat << EOF > remappings.txt
@my-lib/B.sol=my-lib/B.sol
EOF
$ forge build
[⠊] Compiling...
Error:
failed to resolve file: "/Users/t/bench/issues6706/my-lib/B.sol/": Not a directory (os error 20); check configured remappings.
--> "/Users/t/bench/issues6706/src/A.sol"
"@my-lib/B.sol" This change makes it work: diff --git a/remappings.txt b/remappings.txt
index 134e3a5..ceb4244 100644
--- a/remappings.txt
+++ b/remappings.txt
@@ -1 +1 @@
-@my-lib/B.sol=my-lib/B.sol
+@my-lib/=my-lib/ This issue is not related to the recent changes (foundry-rs/compilers#35, foundry-rs/compilers#36). I can confirm the same behavior occurs with an older version of forge. ( The current implementation of remapping resolution does not support this case. See: To simulate that code: fn main() {
use std::path::Path;
let p1 = Path::new("@my-lib/A.sol").strip_prefix(Path::new("@my-lib/A.sol"));
let p2 = Path::new("A.sol").join(Path::new(""));
println!("{:?}, {:?}", p1, p2); // => Ok(""), "A.sol/"
} |
This is correct - you cannot remap individual files, only directories. Not sure if we should count this as a bug or as a feature request, in any case, it might make sense to support this |
I've faced similar issue with dependency that relies on IERC721Metadata.sol. Definitely need some way to account for possible path changes |
The reason is that from 3.4.2 openzepplin has change the path of ERC72Metadata.sol. |
Not directly related but it is not recommended to install older versions of OpenZeppelin as they may have (known) bugs and vulnerabilities. |
Updated the ticket to reflect that this is a feature request, not a bug Related: #7527 |
Component
Forge
Have you ensured that all of these are up to date?
What version of Foundry are you on?
forge 0.2.0 (9e3ab9b 2024-01-04T00:18:01.892563000Z)
What command(s) is the bug in?
forge test
Operating System
macOS (Apple Silicon)
Describe the bug
lib/openzeppelin-contracts/contracts/token/ERC721/extensions/IERC721Metadata.sol
@openzeppelin/contracts/token/ERC721/IERC721Metadata.sol
@openzeppelin/contracts/token/ERC721/=lib/openzeppelin-contracts/contracts/token/ERC721/extensions/
remappings.txt
@openzeppelin/contracts/token/ERC721/IERC721Metadata.sol=lib/openzeppelin-contracts/contracts/token/ERC721/extensions/IERC721Metadata.sol
Error:
failed to resolve file: "/Users/foundry/Developer/foundry/packages/contracts/lib/openzeppelin-contracts/contracts/token/ERC721/extensions/IERC721Metadata.sol/": Not a directory (os error 20); check configured remappings.
remappings.txt
@openzeppelin/contracts/token/ERC721/=lib/openzeppelin-contracts/contracts/token/ERC721/extensions/IERC721Metadata.sol
Error:
failed to resolve file: "/Users/foundry/Developer/foundry/packages/contracts/lib/openzeppelin-contracts/contracts/token/ERC721/extensions/IERC721Metadata.sol/IERC721Metadata.sol": Not a directory (os error 20); check configured remappings.
remappings.txt
@openzeppelin/contracts/token/ERC721/IERC721Metadata.sol=lib/openzeppelin-contracts/contracts/token/ERC721/extensions/
Error:
failed to resolve file: "/Users/foundry/Developer/foundry/packages/contracts/lib/openzeppelin-contracts/contracts/token/ERC721/extensions/": Is a directory (os error 21); check configured remappings.
The text was updated successfully, but these errors were encountered: