# Truffle Upgrades: Error: Artifacts are from different compiler runs

**URL:** <https://forum.openzeppelin.com/t/truffle-upgrades-error-artifacts-are-from-different-compiler-runs/3864>\
**Category:** Upgrades\
**Created:** [September 17, 2020, 2:02pm UTC](https://forum.openzeppelin.com/t/truffle-upgrades-error-artifacts-are-from-different-compiler-runs/3864 "2020-09-17T14:02:24Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alex-dev](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/alex-dev/32/970_2.png) [@Alex-dev](https://forum.openzeppelin.com/u/Alex-dev)\
**Post date:** [September 17, 2020, 2:02pm UTC](https://forum.openzeppelin.com/t/truffle-upgrades-error-artifacts-are-from-different-compiler-runs/3864/1 "2020-09-17T14:02:24Z")

</div>

Hello @abcoathup,

I understand what you're saying ([Deploying to Quorum with OpenZeppelin CLI - #4 by abcoathup](https://forum.openzeppelin.com/t/openzeppelin-deployment-quorum/3832/4)), I decided to go ahead to try deploying and upgrading a contract on a private ethereum blockchain **using the plugin you suggested**. I decided to follow this tutorial: [OpenZeppelin Upgrades: Step by Step Tutorial for Truffle](https://forum.openzeppelin.com/t/openzeppelin-truffle-upgrades-step-by-step-tutorial/3579) but as I deploy the upgraded contract via the **4\_prepare\_upgrade\_boxv2.js** migration (I skipped the ownership transfer as I just wanted to get the upgrade to work), I get an error saying: **"Error: Artifacts are from different compiler runs"**. Artifcats being from a different compiler runs shouldn't cause an issue? Or, how else am I supposed to deploy a new version of a contract.

Here is a more detailed description of what I did so you can try to reproduce the error:

1. mkdir mycontract && cd mycontract  
npm init -y  
npm i --save-dev truffle  
npx truffle init  
npm i --save-dev @openzeppelin/truffle-upgrades

2. Create a Box.sol inside the contracts folder, code:

3. Edit truffle-config.js to use solc version: "^0.5.0"

4. Create a new migration file:

5. Deploy via truffle to local network -\> Everything deploys successfully! 🙂

6. Create new version of contract, BoxV2.sol:

7. Create new migration file:

8. Deploy via truffle again, now it fails ☹ saying:

> Error: Artifacts are from different compiler runs  
> Run a full recompilation using `truffle compile --all` .....  
> ........  
> ...  
> ...

Running **truffle compile -all** as it suggests didn't help. Please let me know what I'm doing wrong here. Thank you very much for your help so far 🙂

---

<div class="post-metadata">

**Author:** ![abcoathup](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/abcoathup/32/415_2.png) [@abcoathup](https://forum.openzeppelin.com/u/abcoathup)\
**Post date:** [September 18, 2020, 3:03am UTC](https://forum.openzeppelin.com/t/truffle-upgrades-error-artifacts-are-from-different-compiler-runs/3864/2 "2020-09-18T03:03:30Z")

</div>

Hi @Alex-dev,

I am sorry that you are having this issue. Thank you so much for creating reproduceable steps.

I ran through what you described and after running into `Error: Artifacts are from different compiler runs` I was able to resolve by running `npx truffle compile --all`.

You can also try deleting `build/contracts` directory. See the documentation for an explanation on this: [https://docs.openzeppelin.com/upgrades-plugins/1.x/faq#why-do-i-have-to-recompile-all-contracts-for-truffle](https://docs.openzeppelin.com/upgrades-plugins/1.x/faq#why-do-i-have-to-recompile-all-contracts-for-truffle)

Would you mind trying that and let me know if you still run into issues.

As an aside, if you want to jump straight to the upgrade you can use [`upgradeProxy`](https://docs.openzeppelin.com/upgrades-plugins/1.x/api-truffle-upgrades#upgrade-proxy)

For completeness, below is the steps I took:

```auto
...
3_prepare.js
============

Error: Artifacts are from different compiler runs
    Run a full recompilation using `truffle compile --all`
    https://zpl.in/upgrades/truffle-recompile-all
...

```

```auto
$ npx truffle compile --all

Compiling your contracts...
===========================
✔ Fetching solc version list from solc-bin. Attempt #1
> Compiling ./contracts/Box.sol
> Compiling ./contracts/BoxV2.sol
> Compiling ./contracts/Migrations.sol
> Compiling @openzeppelin/upgrades/contracts/Initializable.sol
✔ Fetching solc version list from solc-bin. Attempt #1
> Artifacts written to /home/abcoathup/projects/forum/alex-dev/build/contracts
> Compiled successfully using:
   - solc: 0.5.17+commit.d19bba13.Emscripten.clang

```

```auto
$ npx truffle migrate

Compiling your contracts...
===========================
✔ Fetching solc version list from solc-bin. Attempt #1
> Everything is up to date, there is nothing to compile.

Starting migrations...
======================
> Network name: 'development'
> Network id: 1600375667969
> Block gas limit: 6721975 (0x6691b7)

3_prepare.js
============

   Deploying 'BoxV2'
   -----------------
   > transaction hash: 0x4c16a1a5e6607fbeeed00c46380c017c47014d8b6d93bfa39fc80bf465e75221
   > Blocks: 0 Seconds: 0
   > contract address: 0x9561C133DD8580860B6b7E504bC5Aa500f0f06a7
...

```

---

<div class="post-metadata">

**Author:** ![Alex-dev](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/alex-dev/32/970_2.png) [@Alex-dev](https://forum.openzeppelin.com/u/Alex-dev)\
**Post date:** [September 18, 2020, 9:24am UTC](https://forum.openzeppelin.com/t/truffle-upgrades-error-artifacts-are-from-different-compiler-runs/3864/3 "2020-09-18T09:24:02Z")

</div>

Hello @abcoathup,

I deleted the build/contracts directory as you suggested and ran **truffle migrate** again but this caused all the migration files to run again (1. migration, 2. first deploy, 3. second deploy). My understanding is that only the latest migration should be re-run. Otherwise, doesn’t this mean that the old contract is deployed again to a new address which the new contract is “linked” to?

EDIT:  
Using **npx truffle compile -all** doesn’t seem to re-compile the contracts as expected. I am getting the message: **Everything is up to date…**

However, adding the compile all flag to the migrate command seems to do the job. Like so: **npx truffle migrate --compile-all**.

So, I’m not sure if I did something incorrectly. But what I draw from this is that you should always use the “–compile-all” command when migrating.

Cheers & thanks for your detailed response.

---

<div class="post-metadata">

**Author:** ![ThomasEnder](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/thomasender/32/5077_2.png) [@ThomasEnder](https://forum.openzeppelin.com/u/ThomasEnder)\
**Post date:** [April 22, 2021, 9:12am UTC](https://forum.openzeppelin.com/t/truffle-upgrades-error-artifacts-are-from-different-compiler-runs/3864/4 "2021-04-22T09:12:11Z")

</div>

```
npx truffle migrate --compile-all.

```

This seems to work for me too! Thanks!

---

<div class="post-metadata">

**Author:** ![Neo](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/neo/32/6031_2.png) [@Neo](https://forum.openzeppelin.com/u/Neo)\
**Post date:** [May 26, 2021, 10:20pm UTC](https://forum.openzeppelin.com/t/truffle-upgrades-error-artifacts-are-from-different-compiler-runs/3864/5 "2021-05-26T22:20:30Z")

</div>

Me, also.

But, when I tried the upgrade process using basic Box and BoxV2 contracts as per the [tutorial](https://docs.openzeppelin.com/learn/upgrading-smart-contracts?pref=truffle), the additional `--compile-all` argument isn’t required.

So, there must be something about more complex contracts that `upgradeProxy` isn’t able to handle…

---

<div class="post-metadata">

**Author:** ![Leo\_Tran](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/leo_tran/32/9376_2.png) [@Leo\_Tran](https://forum.openzeppelin.com/u/Leo_Tran)\
**Post date:** [October 6, 2021, 3:04am UTC](https://forum.openzeppelin.com/t/truffle-upgrades-error-artifacts-are-from-different-compiler-runs/3864/6 "2021-10-06T03:04:06Z")

</div>

In my case, I found the error is because I installed both global and local truffle.

- `yarn remove truffle` to remove the local installed truffle and keep the global one
- delete all existing artifacts in ./build folder

Now `truffle test` will be normal.

---

<div class="post-metadata">

**Author:** ![gomezgoiri](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/gomezgoiri/32/15983_2.png) [@gomezgoiri](https://forum.openzeppelin.com/u/gomezgoiri)\
**Post date:** [August 10, 2022, 8:12am UTC](https://forum.openzeppelin.com/t/truffle-upgrades-error-artifacts-are-from-different-compiler-runs/3864/7 "2022-08-10T08:12:04Z")

</div>

Another hint if you're having this error: in my case I realized that running [Solidity tests](https://trufflesuite.com/docs/truffle/testing/writing-tests-in-solidity/) together with the test which calls _deployProxy_ was causing this error.

A simple workaround that worked for me is to run both tests separately.

A convenient way to do this is to specify the following snippet in your _package.json_.:

```auto
  "scripts": {
    ...
    "test-sol": "truffle test test/*.sol",
    "test-js": "truffle test test/*.js",
    "test": "npm run test-sol; npm run test-js"
  },

```
