I installed the latest version of truffle, solc, node and also installed new version of openzeppelin-solidity library in my project.

Changed the truffle-config.js to use new solc version. My contract inherits from the openzeppelin library. Now when i run truffle compile, it give me the following error.

Error parsing openzeppelin-solidity/contracts/ownership/Ownable.sol: ParsedContract.sol:8:1: ParserError: Source file requires different compiler version (current compiler is 0.5.2+commit.1df8f40c.Emscripten.clang - note that nightly builds are considered to be strictly less than the released version contract Ownable { ^------^

Here are the versions for everything I'm using:

$truffle version Truffle v5.0.0 (core: 5.0.0) Solidity - 0.5.2 (solc-js) Node v11.4.0

$ solc --version solc, the solidity compiler commandline interface Version: 0.5.2+commit.1df8f40c.Linux.g++

openzeppelin-solidity package.json has this "_from": "openzeppelin-solidity", "_id": "[email protected]", .... "version": "2.0.0"

Now the Ownable contract uses compiler version ^0.4.24, which would be the case for all the contracts in the library.

Any ideas why this is happening and how to fix this?

  • For current version of open-zeppelin (and definitely for earlier versions) - use Truffle 4.1.14 (or earlier). Truffle 5 relies on Solc 0.5.0, while open-zeppelin is still on Solc 0.4.24. Commented Dec 27, 2018 at 12:22

1 Answer 1


Current version of open-zeppelin (2.0.0) relies on solc version 0.4.24.

Current version of truffle (5.0.0) relies on solc version 0.5.0.

Between solc 0.4.x and solc 0.5.x there are breaking changes.

Previous version of truffle (4.1.14) relies on solc version 0.4.24.

So in order to use open-zeppelin in conjunction with truffle, set in your package.json file:

"devDependencies": {
  "truffle": "4.1.14",
  "openzeppelin-solidity": "2.0.0",

Alternatively, in truffle 5.0.0 onward, you can choose the desired version of solc.

For example, in order to configure truffle to use solc 0.4.24, add this in truffle-config.js:

compilers: {
    solc: {
        version: "0.4.24"

See more details in Truffle 5.0.0 release notes for how to bring your own compiler.

  • Thanks for your answer. Would that mean I need to downgrade truffle to version 4.1.14 Commented Dec 27, 2018 at 12:43
  • Btw tried adding that line in package.json too but it didnt help, any suggestions? Commented Dec 27, 2018 at 12:49
  • @SowmyaKannan: You're probably installing truffle globally (and then using it globally). In this case, the answer is yes - you'll need to uninstall it (globally) and then reinstall an older version (4.1.14 in this case). But if you want to follow my way and install it locally, then it means that in order to run truffle you need to execute /node_modules/.bin/truffle from the path where you run npm (instead of truffle from any path). This should work on Windows. a general command line (one that should work on any OS) is node ./node_modules/truffle/build/cli.bundled.js Commented Dec 27, 2018 at 13:39
  • Ok, Thanks for that. I am using Fedora Linux. Will try and let you know. I still feel this is not the optimal way, but as of now we just have to wait till openzeppelin releases a truffle 5.0.0 compatible version or downgrade. Commented Dec 27, 2018 at 14:15
  • 1
    @goodvibration the issue is not about the solc compiler version specified in the config file. The issue is that truffle does not compile the contracts derived from openzeppelin library bcoz of an older solc compiler version used. I had raised this issue with openzeppelin slack too and they are supposed to release a truffle v5 compatible version sometime this week or next. anyway till then will try your suggested work arounds. let me know what exactly you did. Commented Jan 3, 2019 at 6:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.