Truffle: Error: Could not find a compiler version matching 0.5.4.

Created on 12 Feb 2019  Â·  17Comments  Â·  Source: trufflesuite/truffle

  • [x] I've asked for help in the Truffle Gitter before filing this issue.

Issue

I added this to truffle-config.js:

compilers: {
   solc: {
      version: "0.5.4"
    }
  },

An I get this error when running truffle complie

Error: Could not find a compiler version matching 0.5.4. Please ensure you are specifying a valid version, constraint or build in the truffle config. Run `truffle compile --list` to see available versions.
    at VersionRange.errors (/usr/lib/node_modules/truffle/build/webpack:/packages/truffle-compile/compilerSupplier/loadingStrategies/LoadingStrategy.js:57:1)
    at VersionRange.getSatisfyingVersionFromCache (/usr/lib/node_modules/truffle/build/webpack:/packages/truffle-compile/compilerSupplier/loadingStrategies/VersionRange.js:86:1)
    at VersionRange.load (/usr/lib/node_modules/truffle/build/webpack:/packages/truffle-compile/compilerSupplier/loadingStrategies/VersionRange.js:186:1)
    at <anonymous>
Truffle v5.0.3 (core: 5.0.3)
Node v8.15.0

Here is the output of truffle complie --list:

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

Environment

  • Operating System: linux
  • Ethereum client: geth 1.8.22
  • Truffle v5.0.3 (core: 5.0.3)
  • Solidity - ^0.5.3 (solc-js)
  • Node v8.15.0
  • npm version (npm --version):
    { damian: '1.0.0',
    npm: '6.7.0',
    ares: '1.14.0',
    cldr: '32.0.1',
    http_parser: '2.8.0',
    icu: '60.2',
    modules: '57',
    napi: '3',
    nghttp2: '1.33.0',
    node: '8.15.0',
    openssl: '1.1.0i-fips',
    tz: '2017c',
    unicode: '10.0',
    uv: '1.23.2',
    v8: '6.2.414.75',
    zlib: '1.2.11'
    }

Most helpful comment

@saturn-network your workaround worked for me

All 17 comments

Hey @Bowfish, I can't reproduce your error on Truffle v5.0.4. Can you try upgrading and trying again? Let me know if you still have the issue.

@eggplantzzz I update again to 5.0.4 but still the same:

Error: Could not find a compiler version matching 0.5.4. Please ensure you are specifying a valid version, constraint or build in the truffle config. Run `truffle compile --list` to see available versions.
    at VersionRange.errors (/usr/lib/node_modules/truffle/build/webpack:/packages/truffle-compile/compilerSupplier/loadingStrategies/LoadingStrategy.js:57:1)
    at VersionRange.getSatisfyingVersionFromCache (/usr/lib/node_modules/truffle/build/webpack:/packages/truffle-compile/compilerSupplier/loadingStrategies/VersionRange.js:86:1)
    at VersionRange.load (/usr/lib/node_modules/truffle/build/webpack:/packages/truffle-compile/compilerSupplier/loadingStrategies/VersionRange.js:186:1)
    at <anonymous>
Truffle v5.0.4 (core: 5.0.4)
Node v8.15.0

@eggplantzzz If I run truffle compile as root it downloads the compiler, but if I run it as a normal user I get the error.

What do you have in truffle-config.js? If you are having problems depending on user then it starts to sound like a permissions issue on your machine.

Perhaps an easily actionable thing to mitigate this and #1713 is to make three attempts for each HTTP request?

Can't even get through truffle compile --list

Error: Failed to complete request to: https://solc-bin.ethereum.org/bin/list.json. Are you connected to the internet?

Maybe that's the culprit

also having this issue, any workaround @Bowfish

@eggplantzzz here is my truffle-config.js entry:

compilers: {
    solc: {
      version: "0.5.4"
    }
  },

@foodaka If I run truffle compile as a super user it downloads the compiler. When the complier is downloaded I can run truffle complie as a normal user and it is working.

@foodaka see workaround in #1721

@saturn-network This workaround doesn't solve the original issue. I still have to run truffle compile as a superuser and then it downloads the compiler. Once the compiler is downloaded I can run truffle compile as a normal user.

I installed truffle like this as a superuser: npm install -g truffle is that correct or do I have to run the same command as a normal user?

@saturn-network your workaround worked for me

+1 for @saturn-network's workaround. Do note that it's a temporary solution, the urls should start working again.

@Bowfish, if you are having to download as root, that means your file permissions are incorrect somewhere. Usually this happens because you ran “sudo npm something” when you should have just run “npm something”

The docs should probably be changed to not suggest using sudo and instead just install to the local node_modules directory. Then you can use truffle with ./node_modules/.bin/truffle

More info about the problems with using sudo here: https://givan.se/do-not-sudo-npm and https://www.competa.com/blog/how-to-run-npm-without-sudo/

It looks like we have two issues that lead to this error.

For some reason my home network can’t connect to solc-bin.ethereum.org and it’s looking like other people are having the same issue. If I tether to my phone, I can download the binary just fine. Switching to GitHub does workaround the issue, but I’m curious what the actual networking problem is.

The other issue is truffle being installed as root but running as a non-root user which means it can’t save the binary.

@WyseNynja Thank you very much. I was not aware of this. I installed it accordingly and everything works fine.

My original issue has been solved with installing nodejs and npm as a normal user and not as a super user.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

EmanHerawy picture EmanHerawy  Â·  3Comments

arunmitteam picture arunmitteam  Â·  3Comments

oed picture oed  Â·  3Comments

tcurdt picture tcurdt  Â·  3Comments

ysfAskri picture ysfAskri  Â·  4Comments