9

So I have install the Solidity extension for Visual Studio.

V0.0.76 https://github.com/juanfranblanco/vscode-solidity

And when I start my Solidity code with

pragma solidity ^0.5.0;

I get the following error in visual studio.

Source file requires different compiler version (current compiler is 0.7.0+commit.9e61f92b.Emscripten.clang) - note that nightly builds are considered to be strictly less than the released version

However I'm using truffle to compile and when I run truffle version I get

Truffle v5.0.2 (core: 5.0.2)
Solidity v0.5.0 (solc-js)
Node v12.16.3

So my code is compiling but I would like to know how to specify the solidity version to visual code as well to prevent error warning.

2 Answers 2

29

Right click on the error, and change workspace compiler seems work. Right click o

4
  • Il give it to you! Please up vote the question Sep 16, 2020 at 5:08
  • @MadeInDreams thanks man, i want to comment your answer but cannot insert image
    – devnomic
    Sep 16, 2020 at 14:18
  • It`s all good it's better this way! Sep 16, 2020 at 21:09
  • 3
    Still not working for me :(
    – kitta
    Oct 22, 2021 at 12:26
3

If you still have a problem with the version in VS Code, this worked for me:

Install specific solc version locally or globally: npm i -g solc or npm i solc.

Add this setting in local VSCode settings: .vscode/settings.json

{
    "solidity.compileUsingRemoteVersion": "v0.7.4+commit.3f05b770",
    "solidity.enableLocalNodeCompiler": false
}

In my case I am using solidity v0.7.4. Note also the other config: "solidity.enableLocalNodeCompiler": false

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.