Truffle: Misleading error message while trying to compile with an unsupported version

Created on 9 Apr 2019  路  6Comments  路  Source: trufflesuite/truffle

Issue

Misleading error message while trying to compile with an unsupported version

Steps to Reproduce

  1. Start a new project with truffle 5.0.5
  2. Modify your truffle.js or truffle-config.js file to compile your contracts with solc 0.5.3
  3. Create a any new contract using pragma solidity 0.5.7
  4. Run npx truffle compile

Expected Behavior

To throw a more descriptive and accurate error :)

Actual Results

Compiling your contracts...
===========================
Error: TypeError: Cannot read property '0' of null
    at async.whilst.error (~/test/node_modules/truffle/build/webpack:/packages/truffle-compile/profiler.js:375:1)
    at ~/test/node_modules/truffle/build/webpack:/packages/truffle-compile/~/async/dist/async.js:969:1
    at next (~/test/node_modules/truffle/build/webpack:/packages/truffle-compile/~/async/dist/async.js:5222:1)
    at <anonymous>

Environment

  • Operating System: mac osx 10.14.3
  • Truffle version (truffle version): 5.0.5
  • node version (node --version): 9.11.1
  • npm version (npm --version): 6.7.0

Most helpful comment

If you have a Truffle config file setting your solc compiler to a version of 0.5.2 through 0.5.6, one concrete step you can try to confirm this is the issue you're running into is commenting out that solc line in the config in order to use the Truffle default instead (as long as you're using a Truffle version that doesn't default to one of those solc versions) or specifying a newer solc version like 0.5.7.

All 6 comments

Hey @facuspagnuolo! can you try again after upgrading to truffle 5.0.10? I believe we added better erroring to handle your exact scenario, would love to know if it works as expected 馃

@CruzMolina I tried but I'm getting the same error message :(

Ah, well thanks for checking. Will look into this.

Ohhhh, I see. This is a different error. Thanks for reporting @facuspagnuolo !

Wow, okay, so it turns out this is a solc error reporting bug (ethereum/solidity#6329) that's been fixed in 0.5.7. For solc versions 0.5.2 thru 0.5.6, the parsing error was being reported on the wrong line. Will be updating the solc error handling on our side to address this.

If you have a Truffle config file setting your solc compiler to a version of 0.5.2 through 0.5.6, one concrete step you can try to confirm this is the issue you're running into is commenting out that solc line in the config in order to use the Truffle default instead (as long as you're using a Truffle version that doesn't default to one of those solc versions) or specifying a newer solc version like 0.5.7.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rstormsf picture rstormsf  路  3Comments

TOMOAKI12345 picture TOMOAKI12345  路  3Comments

ripper234 picture ripper234  路  4Comments

arunmitteam picture arunmitteam  路  3Comments

abcoathup picture abcoathup  路  3Comments