Truffle Compiler Error – Solving ‘Could Not Find Compiler Version Matching 0.5.0’ in Truffle

soliditytruffletruffle-compiletruffle-contracttruffle-migration

I wonder why I get the error when I have v0.5.0 everywhere and do the following:

In my Action.sol:
pragma solidity ^0.5.0;

In Migrations.sol:
pragma solidity >=0.5.0 <0.6.0;

When running truffle compile I get:

Error: Could not find a compiler version matching 0.5.0. Please ensure you are specifying a valid version, constraint or build in the truffle config. Run `truffle compile --list` to see available versions.

In test-a-smart-contract-with-truffle/truffle-config.js:

  compilers: {
    solc: {
      version: "0.5.0", 

In /usr/local/bin/truffle:

compilers: {
      solc: {
        version: "0.5.0",
        settings: {
          optimizer: {
            enabled: false,
            runs: 200
          },
          evmVersion: "byzantium"
        }
      },
      vyper: {}
    },

But when I run truffle compile --list I get:

[
 "0.5.4",
 "0.5.3",
 "0.5.2",
 "0.5.1",
 "0.5.0",
 "0.4.25",
 "0.4.24",
 "0.4.23",
 "0.4.22",
 "0.4.21",
 ".. and 38 more. Use `--all` to see full list."
]

Best Answer

In my case, I run this following command in order to update truffle: npm install -g truffle@5.0.21