-
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
forge struggles to handle the way pnpm links node_modules in pnpm-workspaces #2714
Comments
I don't think it should be foundry's responsibility to understand all the ways in which the different package managers store and manage their assets. In the case of pnpm for instance you can resolve that by configuring your pnpm workspace with an .npmrc that instructs pnpm to hoist the packages in question. Simply create a
(After that you need to run |
Thanks for the reply @fubhy - preventing pnpm from hoisting to the package root wasn't working for some reason, I didn't manage to solve that (also tried In the end I just made the contracts sub-folder its own pnpm workspace by adding a Not the ideal solution, but it works! |
@JasoonS I see. I looked at your reproduction repo now, missed that before, sorry. I was just assuming that you are refering to the It doesn't solve the problem you are facing though. To get around it, I'd suggest to put to Maybe someone else has a better idea for how this might work. There are some monorepos out there using foundry already e.g. https://github.com/nomad-xyz/monorepo (yarn, granted, but still). That one also uses packages to split up the contracts for instance. |
That makes sense, thanks for the help. I'll experiment around with different configurations. Main thing is that it is all working ✌️ |
I think people just do |
https://github.com/sambacha/forge-scope if you can try running the inportly command to generate the scoped remappings it should work after you have installed your node dependencies ie: root_dir :- $ npx importly < package.json > forge-importmap.json Then transfer the results to remapping.txt or your toml file this will work if you define a resolutions field in your package manifest only |
this is a symlink issue,
so what you need to do is to add:
in you foundry.toml |
@onbjerg added a troubleshooting section for pnpm/symlinks: I'm hesitant to do any more symlink work in ethers-solc, since most of them can be fixed by solc + allow_paths, I vote to close this one as won't fix |
Switch from yarn to pnpm for node package management. #### Motivation [pnpm](https://pnpm.io/) is becoming industry standard for managing node packages. It's lightweight, and removes a lot of bloat from node_modules - using symlinks and ensuring package versions are only installed to disk once. Installations are much quicker. And it has better support for monorepos (pnpm workspaces) should we decide to manage multiple pnpm projects in our monorepo (as [optimism does](https://github.com/ethereum-optimism/optimism/blob/develop/pnpm-workspace.yaml), for example) I've avoided using it in the past alongside foundry because foundry has allegedly had [issues with handling pnpm symlinks](foundry-rs/foundry#2714), but I've tried it in our playground repo and imports work well, for both building & IDE ls integrations. task: none
Component
Forge
Have you ensured that all of these are up to date?
What version of Foundry are you on?
forge 0.2.0 (6cd6618 2022-08-11T00:03:54.64793456Z)
What command(s) is the bug in?
forge build
Operating System
Linux
Describe the bug
This is very likely a duplicate of the original issue here: #1801 - creating a new issue since that issue seems to have been confused with other issues, so maybe a clean conversation is useful.
This issue is only pressent when using pnpm; yarn and npm works fine.
The reproduction of the issue is here: https://github.com/JasoonS/forge-node_module-pnpm-issue-repro
exact steps to run in terminal:
I think this is happening because pnpm is placing the package outside of the contracts folder (in the root of the repo) and sym linking it.
Thank you in advance for taking a look at this issue 🙏
The text was updated successfully, but these errors were encountered: