create-eth-app icon indicating copy to clipboard operation
create-eth-app copied to clipboard

Bug, or clarification needed around `forge install`, and the lib folder

Open positonic opened this issue 1 year ago • 2 comments

I'm using forge with create-eth, and when I run forge install it installs in the lib folder in the root of my project.

I appear to be having an issue with paths though. My packages/foundry/remappings.txt file has the line: oz-upgradeable=/lib/hypercerts/contracts/contracts/lib/openzeppelin-contracts-upgradeable/contracts/

It's throwing an error:

hyperstaker-mono git:(feat-basic-staking) ✗ yarn test                   
[⠊] Compiling...
Error: 
Failed to resolve file: "/Users/james/code/hyperstaker-mono/packages/foundry/lib/hypercerts/contracts/contracts/lib/openzeppelin-contracts-upgradeable/contracts/security/PausableUpgradeable.sol": No such file or directory (os error 2).
 Check configured remappings..
    --> "/Users/james/code/hyperstaker-mono/lib/hypercerts/contracts/contracts/HypercertMinter.sol"
        "oz-upgradeable/security/PausableUpgradeable.sol"

Which basically shows that it's looking for the lib folder relative to the foundry folder: packages/foundry

I'm stuck on how to get around this.

I've tried:

  • passing in a flag - yarn test --lib-paths ./lib
  • adding the flag to packages/foundry/package.json ---> "test": "forge test",

The only way I have been been able to get it working is to hard code the path to the folder like this: oz-upgradeable=/Users/me/code/hyperstaker-mono/lib/hypercerts/contracts/lib/openzeppelin-contracts-upgradeable/contracts/

This is problematic as it's a shared repo which others work on, and I'm a bit confused by this behaviour altogether, and wonder if I'm doing something wrong, or if it's a bug?

positonic avatar Apr 21 '24 15:04 positonic

This project is not meant to be used with Forge. It's a front-end development environment.

For smart contract development, check out my Foundry template:

https://github.com/PaulRBerg/foundry-template

PaulRBerg avatar Apr 23 '24 08:04 PaulRBerg

Also, I recommend against using git submodules:

https://twitter.com/PaulRBerg/status/1736694426578137247

PaulRBerg avatar Apr 23 '24 08:04 PaulRBerg