-
Notifications
You must be signed in to change notification settings - Fork 12.3k
Open
Description
Environment
- OpenZeppelin Contracts Upgradeable v5.3.0
- Node.js (Edit: was on v20+, but upgraded to LTS v22.15.1 with same issue)
- Using
npmandHardhaton macOS - Fresh clone of
openzeppelin-contracts-upgradeable
Details
When running npm run generate on a fresh clone of the repo, the script fails with an ENOENT error if the target directory (e.g., contracts/utils/math/) doesn’t already exist.
This happens because fs.writeFileSync() is called without ensuring the output directory is present.
Code to reproduce bug
-
Clone the repo:
git clone https://github.com/OpenZeppelin/openzeppelin-contracts-upgradeable.git cd openzeppelin-contracts-upgradeable -
Install dependencies:
npm install
-
Run the generator:
npm run generate
-
You’ll see:
Error: ENOENT: no such file or directory, open 'contracts/utils/math/SafeCast.sol'
Suggested Fix
Add this line to scripts/generate/run.js before writing output:
fs.mkdirSync(path.dirname(output), { recursive: true });This ensures the parent directories exist before attempting to write files.
Happy to open a PR if this direction makes sense!
Metadata
Metadata
Assignees
Labels
No labels