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

Forge remappings output wrong with multiple remappings.txt on dependencies. #6431

Open
1 of 2 tasks
Tracked by #9157
Rizary opened this issue Nov 26, 2023 · 7 comments · May be fixed by #9263
Open
1 of 2 tasks
Tracked by #9157

Forge remappings output wrong with multiple remappings.txt on dependencies. #6431

Rizary opened this issue Nov 26, 2023 · 7 comments · May be fixed by #9263
Assignees
Labels
A-compiler Area: compiler A-dependencies Area: dependencies T-bug Type: bug
Milestone

Comments

@Rizary
Copy link

Rizary commented Nov 26, 2023

Component

Forge

Have you ensured that all of these are up to date?

  • Foundry
  • Foundryup

What version of Foundry are you on?

forge 0.2.0 (33f3fee 2023-05-27T00:03:28.386134290Z)

What command(s) is the bug in?

forge flatten -C src -o src/flatten/1.0/MyContract.sol src/1.0/MyContract.sol

Operating System

Linux

Describe the bug

Here's what I run:

$ forge install ProjectOpenSea/seadrop

then I put remappings.txt in my root project as shown on the pic (right side), the other one is from opensea's drop repo (I create another issue see the left side of the pic).

image

What I notice is this:

  1. In the seadrop's remappings.txt, the openzeppelin-contracts remapped to openzeppelin-contracts/contracts
  2. but in the forge remappings output, the /contracts was missing.
@Rizary Rizary added the T-bug Type: bug label Nov 26, 2023
@gakonst gakonst added this to Foundry Nov 26, 2023
@github-project-automation github-project-automation bot moved this to Todo in Foundry Nov 26, 2023
@mattsse
Copy link
Member

mattsse commented Nov 26, 2023

can you please add your remappings as text

@Rizary
Copy link
Author

Rizary commented Nov 26, 2023

@mattsse I have put remappings.txt in the root project.
image

@mattsse
Copy link
Member

mattsse commented Nov 26, 2023

Can you please attach its content as text?

@Rizary
Copy link
Author

Rizary commented Nov 26, 2023

remappings.txt here's my project's remappings.txt

the seadrop's one can be found at their repo.

@Rizary
Copy link
Author

Rizary commented Nov 29, 2023

@mattsse have you been able to reproduce this?

@zerosnacks
Copy link
Member

Hi @Rizary

I've been able to reproduce your report

forge build
[⠃] Compiling...2024-07-05T09:02:44.774804Z ERROR foundry_compilers_artifacts_solc::sources: error="/home/zerosnacks/Projects/counter/lib/seadrop/lib/openzeppelin-contracts/utils/introspection/IERC165.sol": No such file or directory (os error 2)
[⠊] Compiling...
Error: 
failed to resolve file: "/home/zerosnacks/Projects/counter/lib/seadrop/lib/openzeppelin-contracts/utils/introspection/IERC165.sol": No such file or directory (os error 2); check configured remappings
	--> /home/zerosnacks/Projects/counter/lib/seadrop/src/ERC721SeaDrop.sol
	openzeppelin-contracts/utils/introspection/IERC165.sol

As example, following your setup:

// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;

import {ERC721SeaDrop} from "seadrop/src/ERC721SeaDrop.sol";

contract Counter is ERC721SeaDrop {
    uint256 public number;

    address[] public a;

    constructor() ERC721SeaDrop("Counter", "COUNT", a) {}

    function setNumber(uint256 newNumber) public {
        number = newNumber;
    }

    function increment() public {
        number++;
    }
}

With remappings:

forge-std/=lib/forge-std/src/
openzeppelin/=lib/seadrop/lib/openzeppelin-contracts/contracts
seadrop/=lib/seadrop/
openzeppelin-contracts/=lib/seadrop/lib/openzeppelin-contracts/contracts/
openzeppelin-contracts-upgradeable/=lib/seadrop/lib/openzeppelin-contracts-upgradeable/contracts/
utility-contracts/=lib/seadrop/lib/utility-contracts/src/
forge build
[⠊] Compiling...
[⠑] Compiling 3 files with Solc 0.8.17
[⠘] Solc 0.8.17 finished in 3.54s
Compiler run successful!

It looks like the linker gets confused when encountering this remapping, perhaps this is an area of improvement (cc @klkvr) we could look into. For now it is quite easy to work around.

@zerosnacks
Copy link
Member

cc @grandizzy added a repro here: https://github.com/zerosnacks/foundry-bug-6431-repro, issue with automatic remappings remains after latest fixes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-compiler Area: compiler A-dependencies Area: dependencies T-bug Type: bug
Projects
Status: Todo
Development

Successfully merging a pull request may close this issue.

4 participants