vscode-solidity icon indicating copy to clipboard operation
vscode-solidity copied to clipboard

Source file requires different compiler version

Open emiliolanzalaco opened this issue 1 year ago • 13 comments

Hi, I am having some issues with the compiler version.

I am inside of a basic forge init repo. I am trying to use solidity version 0.8.22 but I am locked to 0.8.19 no matter what settings I choose.

Here is my settings.json inside the workspace:

{
    "solidity.compileUsingRemoteVersion": "v0.8.22+commit.4fc1097e",
    "solidity.defaultCompiler": "remote"
}

Here is my solidity file:

// SPDX-License-Identifier: MIT

pragma solidity 0.8.22;

And here is my error:

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

I think this could be a bug. Could someone replicate this?

emiliolanzalaco avatar Nov 08 '23 17:11 emiliolanzalaco

Are you compiling using forge?, you can set the version in foundry.toml [profile.default] solc-version = "0.8.23"

Edit: In vscode-solidity make sure that your workspace settings are the ones you are editing.

juanfranblanco avatar Nov 10 '23 15:11 juanfranblanco

@elanzalaco ^^^

juanfranblanco avatar Nov 10 '23 15:11 juanfranblanco

@juanfranblanco seems like a bug, remote compiler is locked to 0.8.19 and cant change remote compiler version. Have tried everything

emiliolanzalaco avatar Feb 07 '24 23:02 emiliolanzalaco

Seems like this could be a related issue too: https://github.com/juanfranblanco/vscode-solidity/issues/440

emiliolanzalaco avatar Feb 07 '24 23:02 emiliolanzalaco

BTW, just downgraded to v0.0.165 and error has disappeared

emiliolanzalaco avatar Feb 07 '24 23:02 emiliolanzalaco

I have just been testing solidity 24, press F1 and go to User Settings. Then Solidity. And check what version you have in workspace and user. Should be Remote in both and the version you require. It looks looks like your workspace is using the embedded compiler.

juanfranblanco avatar Feb 08 '24 05:02 juanfranblanco

@emiliolanzalaco ^^^ Workspace is your project and overrides others

juanfranblanco avatar Feb 08 '24 05:02 juanfranblanco

It appears that this issue persists in the latest version: v0.0.170.

My .vscode/settings.json:

{
  "solidity.packageDefaultDependenciesContractsDirectory": "src",
  "solidity.packageDefaultDependenciesDirectory": "lib",
  "solidity.formatter": "forge",
  "[solidity]": {
    "editor.formatOnSave": true,
    "editor.defaultFormatter": "JuanBlanco.solidity"
  },
  "solidity.defaultCompiler": "remote",
  "solidity.compileUsingRemoteVersion": "v0.8.23+commit.f704f362"
}

Error: Screenshot 2024-02-16 at 15.39.44

As a current workaround, I am using a local compiler:

{
  "solidity.packageDefaultDependenciesContractsDirectory": "src",
  "solidity.packageDefaultDependenciesDirectory": "lib",
  "solidity.formatter": "forge",
  "[solidity]": {
    "editor.formatOnSave": true,
    "editor.defaultFormatter": "JuanBlanco.solidity"
  },
  "solidity.defaultCompiler": "localFile",
  "solidity.compileUsingLocalVersion": "/Users/pyk/github/pyk/zkevm-stb/soljson-v0.8.23+commit.f704f362.js"
}

pyk avatar Feb 16 '24 08:02 pyk

@juanfranblanco it appears this is a bug as there are a few cases with similar setups. Seems like the compiler is stuck on v0.8.19 irrespective of global or workspace settings. Would appreciate if you could look into fixing this 🙏🏼

emiliolanzalaco avatar Feb 16 '24 14:02 emiliolanzalaco

Same issue here, both user and workspace are set to either latest or 24, but it's always stuck on 19. Tried reinstalling and manually deleting the plugin folder.

boyuanx avatar Feb 18 '24 09:02 boyuanx

plus one, the remote compiler is stuck at 0.8.19

regohiro avatar Feb 21 '24 05:02 regohiro

This seems to be fixed with the latest update.

boyuanx avatar Feb 22 '24 20:02 boyuanx

The issue was related to the standalone language server pull, that defaults the values to latest so the server won't require to set any values to start with. Whilst this makes sense, the user values were overridden on vscode as they weren't taking preference for a millisecond and not reloaded. *Latest" has been stuck in 19 on the solidity binaries for a few releases now, and there is nothing it can be done about that.

juanfranblanco avatar Feb 27 '24 05:02 juanfranblanco