1

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."
]

2 Answers 2

1

In my case, I run this following command in order to update truffle: npm install -g [email protected]

23

It's solved by running with elevated permissions once: sudo truffle compile - that will download the compiler and then you can continue using non-elevated command truffle compile. That is most probably an issue with a folder permissions on your system, but I wasn't able to figure out which exactly folder that would be. The above fix worked for me and others I recommended it to offline, so there's a good chance it will work for you as well.

1
  • In most cases using sudo is a bad idea, it may work but it is likely you have another problem, like bad permissions, or a bad installation. In the long term it will be better if you fix those problems.
    – Ismael
    Jul 24, 2022 at 18:57

Your Answer

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

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