Fix the infamous "Source file requires different compiler version"

One of the first things you do when starting a new development path is setting up your dev environment. Personally, as a Visual Studio Code believer, I browse the available extensions and install the ones with the most stars ⭐

In my case, I'm starting a new adventure towards the Dapp developer path, so I installed all the solidity/ethereum related extensions I saw. Then, I played around with Cryptozombies and the Truffle tutorial. Both, to my dismay, greeted me with an error when I followed through them in my editor:

Source file requires different compiler version (current compiler is *something*) - note that nightly builds are considered to be strictly less than the released version
❗ avoid using experimental features! avoid specifying version ^

And I haven't written even one line of code of my own!!!

Ok, to the point

What's causing the Source file requires different compiler version error, and how to fix it?


It's the solidity extension.


Because it comes bundled with its own solidity compiler (which is the latest), and most of the tutorials around are using an older version of the language.


Change the source of the compiler for the extension:

  • Open the command palette ctrl+p
  • Type > followed by Change the default workspace
  • Select remote and then Change Global compiler version (Remote) to your version, or an option that suits your project the best. You can read more about it here
  • Keep the grind
  • Latest posts

    © 2021 Cesar Varela 👋 Thanks for visiting!