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.
truffle version
output? Truffle should download the compiler in the project files, so you shouldn't need to download them separately withnpm -g ..
.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