I faced an error like below
Error: Truffle is currently using solc 0.6.6, but one or more of your contracts specify "pragma solidity ^0.5.0".
I’ve already changed the version of all contracts in my project to > 0.6.6 but still, this error doesn’t disappear.
Environment
Truffle v5.1.37 (core: 5.1.37)
Node v10.16.0
compilers version: “0.6.6”,
Details
currently, I’m trying to compile my solidity codes but facing several errors with imported openzeppelin codes like below.
$ truffle compile
Compiling your contracts...
===========================
.
.
> Compiling @openzeppelin/contracts/math/SafeMath.sol
> Compiling @openzeppelin/contracts/token/ERC20/ERC20.sol
> Compiling @openzeppelin/contracts/token/ERC20/IERC20.sol
> Compiling @openzeppelin/contracts/token/ERC20/SafeERC20.sol
@openzeppelin/contracts/math/SafeMath.sol:1:1: ParserError: Source file requires different compiler version (current compiler is 0.6.6+commit.6c089d02.Emscripten.clang - note that nightly builds are considered to be strictly less than the released version
pragma solidity ^0.5.0;
^---------------------^
,@openzeppelin/contracts/token/ERC20/ERC20.sol:1:1: ParserError: Source file requires different compiler version (current compiler is 0.6.6+commit.6c089d02.Emscripten.clang - note that nightly builds are considered to be strictly less than the released version
pragma solidity ^0.5.0;
^---------------------^
,@openzeppelin/contracts/token/ERC20/IERC20.sol:1:1: ParserError: Source file requires different compiler version (current compiler is 0.6.6+commit.6c089d02.Emscripten.clang - note that nightly builds are considered to be strictly less than the released version
pragma solidity ^0.5.0;
^---------------------^
,@openzeppelin/contracts/token/ERC20/SafeERC20.sol:1:1: ParserError: Source file requires different compiler version (current compiler is 0.6.6+commit.6c089d02.Emscripten.clang - note that nightly builds are considered to be strictly less than the released version
pragma solidity ^0.5.0;
^---------------------^
Error: Truffle is currently using solc 0.6.6, but one or more of your contracts specify "pragma solidity ^0.5.0".
Please update your truffle config or pragma statement(s).
(See https://truffleframework.com/docs/truffle/reference/configuration#compiler-configuration for information on
configuring Truffle to use a specific solc compiler version.)
what makes me confused is these imported oppenzellin contract’s versions are not automatically updated to the same(^0.6.0) as contracts that import them.
How can I specify the version of these imported contracts that seems I’m not able to change manually to 0.6.6? or is there no way to do that?
Actually, I’ve already tried to change the versions of all my contracts to 0.5.0 in order to avoid this error but ( as expected…) it threw other errors. So I’d like to find out a better way.
*just in case, the source code that i forked and tried to compile is https://github.com/Goyemon/aave-flash-loans/tree/main/contracts. Some of the contracts of this project import above openzeppelin contracts.
thanks!
Code to reproduce