0

When I truffle compile, it says "Error: Could not find a compiler version matching ^0.8.11". I did some research and installed solc (npm install -g [email protected]), but it didn't fix the error.

In my smart contract I have pragma solidity ^0.8.11; declared at the top, and solcjs --version outputs 0.8.11+commit.d7f03943.Emscripten.clang. I also have the following in my project folder's truffle-config.js:

module.exports = {

  networks: {
    //All code in here is commented out by default
  },

  // Set default mocha options here, use special reporters etc.
  mocha: {
    // timeout: 100000
  },

  // Configure your compilers
  compilers: {
    solc: {
      version: "0.8.11",    // Fetch exact version from solc-bin (default: truffle's version)
      // docker: true,        // Use "0.5.1" you've installed locally with docker (default: false)
      // settings: {          // See the solidity docs for advice about optimization and evmVersion
      //  optimizer: {
      //    enabled: false,
      //    runs: 200
      //  },
      //  evmVersion: "byzantium"
      // }
    }
  },
}

This GitHub issue here determined that issue was a permissions error where Solidity couldn't read from the compilers folder, but I own the truffle folder & gave everybody read+write permissions in an attempt to allow Solidity to find the compiler inside:

15:21:38 [<user>@<server>1t2:1 /usr/local/lib/node_modules]
$ ls -al
drwxr-xr-x  3 vabzbt teusers 236 Feb 22 14:51 solc
drwxr-xr-x  6 vabzbt teusers 180 Feb 21 14:42 truffle

Why is Truffle still unable to find the version of solc that I installed? I tried removing the ^ or changing it to > in my pragma solidity statement & truffle-config info but neither of those worked. fwiw, this is on an enterprise machine that can't connect to the internet, and is mostly limited to internal mirrors of repos & such.

3
  • Can you share the truffle-config.js file? What's truffle version output? Truffle should download the compiler in the project files, so you shouldn't need to download them separately with npm -g ...
    – Ismael
    Feb 25, 2022 at 6:08
  • truffle version gives Truffle 5.5.1, Ganache 7.0.1, Solidity 0.8.11, Node 10.19.0, Web3.js 1.5.3. I edited above to show the full truffle-config.js
    – Josh D
    Feb 25, 2022 at 13:54
  • I'd suggest to start with an empty project in a new folder just copying the truffle-config.js and then start adding the sol files. If it fails with just the config file then there's a problem with truffle installation.
    – Ismael
    Feb 25, 2022 at 15:17

1 Answer 1

0

We have a solution!

I determined that this was a proxy error, but I don't know how to solve it. When truffle compile was run, it had issues connecting to the internet to get potential compiler versions.

As a workaround, You can download the relevant Solidity version at https://github.com/ethereum/solc-bin/tree/gh-pages/bin, and put it in ~/.config/truffle/compilers/node_modules. It does NOT work to download solc through npm and move it from /usr/local/lib/node_modules to the /.config/truffle/... folder.

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.