OpenZeppelin / solidity-docgen

Documentation generator for Solidity projects
MIT License
441 stars 116 forks source link

docgen using wrong solc inside truffle #450

Closed Lem0nTree closed 9 months ago

Lem0nTree commented 9 months ago

Hello, I almost lost one day trying to make run docgen on truffle, without any result unfortunately. Here some specs: truffle --version Truffle v5.11.5 (core: 5.11.5) Ganache v7.9.1 Solidity - 0.8.21 (solc-js) Node v16.20.0 Web3.js v1.10.0

npm solc --version 8.19.4

solidity-doccgen --version 0.5.17

Using truffle compile everything works properly and contracts get compiled.

When trying to runyarn solidity-docgen got this error

    Error: Solidity was unable to compile. contracts/MockERC20.sol:5:1: ParserError: Source file requires different compiler version (current compiler is 0.6.12+commit.27d51765.Emscripten.clang) - 
    note that nightly builds are considered to be strictly less than the released version
    pragma solidity ^0.8.0;
    ^---------------------^
     (And 2 other errors...)

Seems docgen is using solc 0.6.12 instead of the actual 8.19.4

Thank you to anybody helping me solving this 🙌

frangio commented 9 months ago

You need to install the compiler and pass a flag. See this note in the readme for version 0.5: https://github.com/OpenZeppelin/solidity-docgen/tree/0.5#solidity-07

Lem0nTree commented 9 months ago

Solved with

npm install -D solc-0.8.21@npm:solc@^0.8.21  
yarn solidity-docgen --solc-module solc-0.8.21