Remix compilation fails with Source file requires different compiler version

Why am I getting these errors compiling my contracts that all worked in nov or dec? its like everything changed and none of my contracts compile? Can some help w/these errors? It is happening with all my contracts???

https://github.com/OpenZeppelin/openzeppelin-contracts/blob/release-v2.5.0/contracts/token/ERC20/IERC20.sol:1:1: SyntaxError: Source file requires different compiler version (current compiler is 0.5.0+commit.1d4f565a.Emscripten.clang - note that nightly builds are considered to be strictly less than the released version pragma solidity ^0.6.0;

1 Like

Hi @Tedmcm,

Can you share an example contract that is failing to compile?

I assume you have changed the compiler version to an appropriate version for your contract. For OpenZeppelin Contracts 2.5.0 (please note the latest version of 2.x is 2.5.1) uses Solidity 0.5 and not Solidity 0.6.

What is this error? I did a couple of mock ICOs last yr and deployed them on a local network w/ganache… and then on a test network… and now when i try to compile them i get tons of errors… help ?

pragma solidity ^0.5.5;

import "./PetrolCoin.sol";
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/release-v2.5.1/contracts/crowdsale/Crowdsale.sol";
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/release-v2.5.1/contracts/crowdsale/emission/MintedCrowdsale.sol";
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/release-v2.5.1/contracts/crowdsale/validation/CappedCrowdsale.sol";
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/release-v2.5.1/contracts/crowdsale/validation/TimedCrowdsale.sol";
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/release-v2.5.1/contracts/crowdsale/distribution/RefundablePostDeliveryCrowdsale.sol";


// @TODO: Inherit the crowdsale contracts
contract PetrolCoinSale is Crowdsale, MintedCrowdsale, CappedCrowdsale, TimedCrowdsale, RefundablePostDeliveryCrowdsale{

    constructor(
        uint rate,
        address payable wallet,
        PetrolCoin token, 
        uint goal,
        uint openingTime, 
        uint closingTime
        
    )
        TimedCrowdsale(openingTime, closingTime)
        RefundableCrowdsale(goal)
        CappedCrowdsale(goal)
       
        
        Crowdsale(rate, wallet, token)
        public
    {
        // constructor can stay empty
    }
}
      
contract PetrolCoinSaleDeployer {
    address public petrol_sale_address;
    address public token_address;

    constructor(
        string memory name,
        string memory symbol,
        address payable wallet, // this address will receive all Ether raised by the sale
        uint goal
    )
        public
    {
        // @TODO: create the PetrolCoin and keep its address handy
        PetrolCoin token = new PetrolCoin(name, symbol, 0);
        token_address = address(token);
        
        
        // @TODO: create the PetrolCoinSale and tell it about the token, set the goal, and set the open and close times to now and now + 24 weeks.
        PetrolCoinSale petrol_sale = new PetrolCoinSale(1000000000000000000, wallet, token, goal, now, now + 60 minutes);
        petrol_sale_address = address(petrol_sale);
        
        // make the PetrolCoinSale contract a minter, then have the PetrolCoinSaleDeployer renounce its minter role
        token.addMinter(petrol_sale_address);
        token.renounceMinter();
    }
}

This worked fine before… and now i get errors in the imports… I did one that was exactly the same and the errors i get are different and i cant understand how that is possible when the code is exactly the same… did the imports for these change to??

invalid input source specified?

This is the error i get for one of the contracts… and for the other one which is virtually identical i get 19 errors in the imports… i dont know how that is possible…

I do not find release-v2.5.1, there is only 2.5.0

So maybe you should change it to as following and have a try

import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/release-v2.5.0/contracts/crowdsale/Crowdsale.sol";

XXX
1 Like

Thats what it was orignially and it errors 19 errors in the imports. i changed it to 2.5.1 when you recommended the change in erc20 versions earlier to 2.5.1… so i thought maybe it was supposed to change in these imports to… lol… here is the error message w/2.5.0… this contract used to work fine… i did numerous mock ico’s with it in a local network, test networks and it was all fine… now its giving mass errors…

.

Hi @Skyge & @Tedmcm,

We should use the tag in GitHub rather than a branch. Official releases of OpenZeppelin Contracts are tagged.

The import using the v2.5.1 tag is as follows:

import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v2.5.1/contracts/crowdsale/Crowdsale.sol";

I was having some issues with Remix if I had contracts open using other versions of Solidity. I closed other contracts and was getting close to compiling (I didn’t have PetrolCoin).

pragma solidity ^0.8.0;

import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v4.0.0-beta.0/contracts/token/ERC20/ERC20.sol";

contract Token is ERC20 {
  
    constructor () ERC20("TEDY", "TEDY") {
        _mint(msg.sender, 1000000 * (10 ** uint256(decimals())));
    }
}
1 Like

does this compile for you?

1 Like

Hi @Tedmcm,

It didn’t compile for me the first time, giving me an error.
I changed to the Release Candidate (I changed the GitHub import) and checked the Solidity compiler version and was able to compile.

I assume there may be some sort of caching issue.

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v4.0.0-rc.0/contracts/token/ERC20/ERC20.sol";

contract Token is ERC20 {
  
    constructor () ERC20("TEDY", "TEDY") {
        _mint(msg.sender, 1000000 * (10 ** uint256(decimals())));
    }
}

You could also try removing the github directory.

Another community member also had a similar issue: Remix: Parse error : source file requires different compiler version - #2 by abcoathup

The Remix team have created an issue for this: https://github.com/ethereum/remix-project/issues/991

That new one worked! thanks. I think sometimes I was not waiting long enough.. the little green area over the compile button was not finished loading the new version, for some reason its taking a really long time for it to change.. there is that slight green thinking thing over the button and then it goes away.... it takes a long time to reset.. thx!

| abcoathup :zap: OpenZeppelin Team
March 22 |

  • | - |

Hi @Tedmcm,

It didn’t compile for me the first time, giving me an error.
I changed to the Release Candidate (I changed the GitHub import) and checked the Solidity compiler version and was able to compile.

I assume there may be some sort of caching issue.

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v4.0.0-rc.0/contracts/token/ERC20/ERC20.sol";

contract Token is ERC20 {
  
    constructor () ERC20("TEDY", "TEDY") {
        _mint(msg.sender, 1000000 * (10 ** uint256(decimals())));
    }
}

You could also try removing the github directory.

Another community member also had a similar issue: Remix: Parse error : source file requires different compiler version - #2 by abcoathup

1 Like