ethereum / remix-project

Remix is a browser-based compiler and IDE that enables users to build Ethereum contracts with Solidity language and to debug transactions.
https://remix-ide.readthedocs.io
MIT License
2.41k stars 916 forks source link

Reports of Parse error : source file requires different compiler version #991

Open ryestew opened 3 years ago

ryestew commented 3 years ago

Please see: https://forum.openzeppelin.com/t/remix-compilation-fails-with-source-file-requires-different-compiler-version/6029/9

onigiri-x commented 3 years ago

Bump on this - I literally can't do anything with remix.

ghost commented 3 years ago

Oh how I hate Remix!!!

I HATE IT!!

ghost commented 3 years ago

I'm having the same issue. I'm trying to interact with uniswap but keep getting this error. I tried deleting the github directory as suggested by another user, but still keep getting this error.

Screenshot 2021-07-08 at 16-39-14 Remix - Ethereum IDE

Screenshot 2021-07-08 at 16-37-51 Remix - Ethereum IDE

undermethod commented 3 years ago

Likewise, attempting to compile a contract in the browser Remix with ^0.6.12, having selected 0.6.12, but an eventual import from openzeppelin that has ^0.8.0 (albeit working fine using hardhat compile), even after moving the .github directory, still throws the "ParserError" message. image

undermethod commented 3 years ago

What worked for me for the above:

  1. I was using remixd, and needed to:

    # get into an elevated interactive shell:
    sudo -i
    # (your password)
    
    # rather than installing "remixd" plain globally, I had to qualify it:
    npm i -g @remix-project/remixd
    
    # ensure it's 0.5:
    remixd --version
    # should output >= 0.5.0
  2. Launch the browser version of Remix:

    • The -alpha version wasn't working for me, I had to use the regular version.
    • Select the Solidity Compiler tab and choose your version from the Compiler dropdown to produce the correct URL.
  3. Launch remixd:

    • I had to use the shared folder path -s flag without spaces and without quotes for it to work. If you have spaces in your path, I'd suggest renaming folders until there are no spaces and don't use double-quotes.
    • I had to copy/paste the exact url, namely:
      • with https at the beginning
      • with the optimize, runs, evmVersion, and version params
      • without a slash at the end
      • e.g. https://remix.ethereum.org/#optimize=true&runs=200&evmVersion=null&version=soljson-v0.8.7+commit.e28d00a7.js
    • Paste the URL into the remix-ide url -u flag with double-quotes:
      remixd -s /absolute/path/to/your/shared/dir -u "https://remix.ethereum.org/#optimize=true&runs=200&evmVersion=null&version=soljson-v0.8.7+commit.e28d00a7.js"
  4. Return to Remix and select the File explorers tab, change the Workspaces dropdown to localhost and click Connect. Make sure remixd shows at least the line:

    [INFO] <your locale datetime> remixd is listening on 127.0.0.1:65520

    among other lines, and that it doesn't return control to the terminal, it should look like it's hanging.

  5. I was able to then compile, select Injected Web3 to use MetaMask and I was off to the races without open-zeppelin compiler version mismatch errors (despite also using solc < 0.8 as indicated by the error message).

Hope that helps. YMMV. Good luck!

ghost commented 3 years ago

I gave up on a smart contracts concluding that technology this cumbersome and aggravating is doomed to failure.

On Thu, Aug 19, 2021, 10:45 AM Shaun Lerner @.***> wrote:

What worked for me for the above https://github.com/ethereum/remix-project/issues/991#issuecomment-897204893 :

1.

I was using remixd, and needed to:

get into an elevated interactive shell:

sudo -i

(your password)

rather than installing "remixd" plain globally, I had to qualify it:

npm i -g @remix-project/remixd

ensure it's 0.5:

remixd --version

should output >= 0.5.0

2.

Launch the browser version of Remix:

  • The -alpha https://remix-alpha.ethereum.org version wasn't working for me, I had to use the regular https://remix.ethereum.org version.

    • Select the Solidity Compiler tab and choose your version from the Compiler dropdown to produce the correct URL. 3.

    Launch remixd:

  • I had to use the shared folder path -s flag without spaces and without quotes for it to work. If you have spaces in your path, I'd suggest renaming folders until there are no spaces and don't use double-quotes.

    Return to Remix and select the File explorers tab, change the Workspaces dropdown to localhost and click Connect. Make sure remixd shows at least the line: [INFO] remixd is listening on 127.0.0.1:65520 among other lines, and that it doesn't return control to the terminal, it should look like it's hanging. 5.

    I was able to then compile, select Injected Web3 to use MetaMask and I was off to the races without open-zeppelin compiler version mismatch errors (despite also using solc < 0.8 as indicated by the error message).

Hope that helps. YMMV. Good luck!

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/ethereum/remix-project/issues/991#issuecomment-902023538, or unsubscribe https://github.com/notifications/unsubscribe-auth/AOVLZWP5FFHGZQ66SXNKGBLT5URKBANCNFSM4ZSKYM5Q . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&utm_campaign=notification-email .

kursattuncel commented 2 years ago

This problem still continues in Remix 0.21.1, hosted version. Oddly, this particular version of Remix only allows single compiler version:

image

latest local version - soljson-v0.8.7+commit.e28d00a7.js

When trying to compile MyLootBox.sol example from OpenZeppellin, following error is thrown.

ParserError: Source file requires different compiler version (current compiler is 0.8.7+commit.e28d00a7.Emscripten.clang) - note that nightly builds are considered to be strictly less than the released version
 --> MyLootBox.sol:1:1:
  |
1 | pragma solidity ^0.5.11;
  | ^^^^^^^^^^^^^^^^^^^^^^^^
developerasun commented 2 years ago

I have faced with this issue while trying to compile a contract with Solidity ver 0.6.6.

dependencies are:

It was compiled after when I changed pragma version from 0.6.6 to 0.8.15, which is the latest Solidity version at the time.