# Persistent "Stable interface compatibility check failed" error

**URL:** <https://forum.dfinity.org/t/persistent-stable-interface-compatibility-check-failed-error/11281>\
**Category:** Command Line Tools\
**Created:** [March 4, 2022, 12:49am UTC](https://forum.dfinity.org/t/persistent-stable-interface-compatibility-check-failed-error/11281 "2022-03-04T00:49:54Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![mymikemiller](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/mymikemiller/32/694_2.png) [@mymikemiller](https://forum.dfinity.org/u/mymikemiller)\
**Post date:** [March 4, 2022, 12:49am UTC](https://forum.dfinity.org/t/persistent-stable-interface-compatibility-check-failed-error/11281/1 "2022-03-04T00:49:55Z")

</div>

If I have a canister that contains a stable Trie, I get the following message every time I try to deploy, even if I’ve made no changes since the last time I deployed:

```auto
WARNING!
Stable interface compatibility check failed for canister 'stability'.
Upgrade will either FAIL or LOSE some stable variable data.

.../ic-projects/stability/.dfx/local/canisters/stability/stability.old.most:2.39-2.40: syntax error [M0001], unexpected token '/', expected one of token or <phrase> sequence:
  }
  <typ_args>?
  ; seplist(<typ_field>,<semicolon>)
  or <typ>
  . <id>
  -> <typ_nobin>
  and <typ>

Do you want to proceed? yes/No

```

I have to answer “yes” every time I want to deploy, even if no stability-disrupting changes have been made. The only way I can get dfx to not ask me is to delete the .dfx folder or restart dfx with --clean specified, but then of course I run into the same issue the next time I try to deploy. Possibly the error in the .old.most file mentioned in the warning is causing the comparison to consider any changes as stability-breaking.

Here are the contents of stability.old.most:

```auto
type Branch<K, V> = {left : Trie<K, V>; right : Trie<K, V>; size : Nat};
type Leaf<K, V> = {keyvals : AssocList/1<Key<K>, V>; size : Nat};
actor {
  stable var test :
    {#branch : Branch<Nat, Nat>; #empty; #leaf : Leaf<Nat, Nat>}
};

```

This happens with the default project created with “dfx new” under dfx 0.9.2 if a stable variable like the following is in the actor, even if it’s not new or changed between deploys:

`stable var test : Trie.Trie<Nat, Nat> = Trie.empty();`

But not when the stable variable is a Nat, for example:

`stable var test : Nat = 1;`

---

<div class="post-metadata">

**Author:** ![jzxchiang](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/jzxchiang/32/2592_2.png) [@jzxchiang](https://forum.dfinity.org/u/jzxchiang)\
**Post date:** [March 5, 2022, 5:48am UTC](https://forum.dfinity.org/t/persistent-stable-interface-compatibility-check-failed-error/11281/2 "2022-03-05T05:48:27Z")

</div>

Yes I’m getting the same error… No changes to any of my files (git status returns nothing)… but when I run `dfx deploy` I get this error (which I can override by typing in Yes but still…):

```auto
Installing canisters...
WARNING!
Stable interface compatibility check failed for canister 'service'.
Upgrade will either FAIL or LOSE some stable variable data.

/Users/justinchiang/project/.dfx/local/canisters/service/service.old.most:19.10-19.11: syntax error [M0001], unexpected token '/', expected one of token or <phrase> sequence:
  = <typ>
  < seplist(<typ_bind>,,) > = <typ>

Do you want to proceed? yes/No
No
Error: Refusing to install canister without approval

```

Line 19 of that file is this:

```auto
type Char/2 = Char/1;

```

@chenyan have you happened to have seen this before? Thanks.

---

<div class="post-metadata">

**Author:** ![chenyan](https://avatars.discourse-cdn.com/v4/letter/c/35a633/32.png) [@chenyan](https://forum.dfinity.org/u/chenyan)\
**Post date:** [March 5, 2022, 4:07pm UTC](https://forum.dfinity.org/t/persistent-stable-interface-compatibility-check-failed-error/11281/3 "2022-03-05T16:07:04Z")

</div>

This will be fixed in the next `moc` release. You can also patch this PR ([bugfix: fix pretty printing of types and #3128 by crusso · Pull Request #3130 · dfinity/motoko · GitHub](https://github.com/dfinity/motoko/pull/3130)) if you want to build it yourself.

---

<div class="post-metadata">

**Author:** ![claudio](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/claudio/32/322_2.png) [@claudio](https://forum.dfinity.org/u/claudio)\
**Post date:** [March 5, 2022, 9:32pm UTC](https://forum.dfinity.org/t/persistent-stable-interface-compatibility-check-failed-error/11281/4 "2022-03-05T21:32:03Z")

</div>

Yeah, sorry folks, that’s my bad.

I could put out another release of moc tomorrow, if you know how to patch your dfx to use it. Environment variable DFX\_MOC\_PATH apparently let’s you repoint dfx to another moc, though I’ve never tried it.

---

<div class="post-metadata">

**Author:** ![claudio](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/claudio/32/322_2.png) [@claudio](https://forum.dfinity.org/u/claudio)\
**Post date:** [March 5, 2022, 10:18pm UTC](https://forum.dfinity.org/t/persistent-stable-interface-compatibility-check-failed-error/11281/5 "2022-03-05T22:18:09Z")

</div>

There’s a new release of moc you can try here:

> **[Release 0.6.23 · dfinity/motoko](https://github.com/dfinity/motoko/releases/tag/0.6.23)**
>
> motoko (moc)
> 
> 
> bugfix: fix pretty printing of (stable) types and #3128 (#3130)
> 
> Collect constructors transitively before emitting a .most file.
> Modifies type pretty printer to produce well-formed ...

If you manage to try it, please let me know if it works for you.

---

<div class="post-metadata">

**Author:** ![jzxchiang](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/jzxchiang/32/2592_2.png) [@jzxchiang](https://forum.dfinity.org/u/jzxchiang)\
**Post date:** [March 6, 2022, 5:08am UTC](https://forum.dfinity.org/t/persistent-stable-interface-compatibility-check-failed-error/11281/6 "2022-03-06T05:08:22Z")

</div>

> [@claudio](#):
>
> [Release 0.6.23 · dfinity/motoko · GitHub](https://github.com/dfinity/motoko/releases/tag/0.6.23)

I just tried it, but unfortunately it throws a new error when running `dfx build` (so even before the canister installation step):

```auto
stable-types:6.6-6.15: type error [M0051], duplicate definition for type AssocList in block

```

I confirmed this issue does not exist in 0.6.21.

---

<div class="post-metadata">

**Author:** ![claudio](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/claudio/32/322_2.png) [@claudio](https://forum.dfinity.org/u/claudio)\
**Post date:** [March 6, 2022, 9:30am UTC](https://forum.dfinity.org/t/persistent-stable-interface-compatibility-check-failed-error/11281/7 "2022-03-06T09:30:03Z")

</div>

OK, that’s not good. Thanks for trying!

You might want to stick with 0.6.21(or 0  
6.22) for now since you can at least ignore the dfx warning.

0.6.23 should actually fail to produce a binary if there is something wrong with the ‘.most’ file or custom section (it does an extra sanity check).

---

<div class="post-metadata">

**Author:** ![claudio](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/claudio/32/322_2.png) [@claudio](https://forum.dfinity.org/u/claudio)\
**Post date:** [March 6, 2022, 8:54pm UTC](https://forum.dfinity.org/t/persistent-stable-interface-compatibility-check-failed-error/11281/8 "2022-03-06T20:54:14Z")

</div>

I think I’ve found and fixed the bug in 0.6.23.

If you get a chance, please try the newest release, moc 0.6.24, and let me know how that works for you.

> **[Release 0.6.24 · dfinity/motoko](https://github.com/dfinity/motoko/releases/tag/0.6.24)**
>
> motoko (moc)
> 
> bugfix: fix bogus identification of distinct type constructors
> in --stable-types section and .most file (#3140)

---

<div class="post-metadata">

**Author:** ![jzxchiang](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/jzxchiang/32/2592_2.png) [@jzxchiang](https://forum.dfinity.org/u/jzxchiang)\
**Post date:** [March 7, 2022, 7:39am UTC](https://forum.dfinity.org/t/persistent-stable-interface-compatibility-check-failed-error/11281/9 "2022-03-07T07:39:36Z")

</div>

Hmm, I ran it again on 0.6.24, and that error went away but now I have a different error:

```auto
stable-types:33.16-33.23: type error [M0029], unbound type Char__1

```

Same as before—exit code is 255.

---

<div class="post-metadata">

**Author:** ![claudio](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/claudio/32/322_2.png) [@claudio](https://forum.dfinity.org/u/claudio)\
**Post date:** [March 7, 2022, 8:20am UTC](https://forum.dfinity.org/t/persistent-stable-interface-compatibility-check-failed-error/11281/10 "2022-03-07T08:20:27Z")

</div>

OK, thanks for checking. Guess I’ll be working on that today ;-\>

---

<div class="post-metadata">

**Author:** ![claudio](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/claudio/32/322_2.png) [@claudio](https://forum.dfinity.org/u/claudio)\
**Post date:** [March 7, 2022, 5:13pm UTC](https://forum.dfinity.org/t/persistent-stable-interface-compatibility-check-failed-error/11281/11 "2022-03-07T17:13:38Z")

</div>

I’m a little embarrassed to ask, but could you try:

> **[Release 0.6.25 · dfinity/motoko](https://github.com/dfinity/motoko/releases/tag/0.6.25)**
>
> motoko (moc)
> 
> bugfix: fix bogus elision of type constructors sharing names with primitive types in --stable-types section and .most file (#3140)

and see if it fixes this issue?

---

<div class="post-metadata">

**Author:** ![mymikemiller](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/mymikemiller/32/694_2.png) [@mymikemiller](https://forum.dfinity.org/u/mymikemiller)\
**Post date:** [March 7, 2022, 5:37pm UTC](https://forum.dfinity.org/t/persistent-stable-interface-compatibility-check-failed-error/11281/12 "2022-03-07T17:37:41Z")

</div>

I’d be happy to try, but I’m not sure how. Can you point to some resources explaining how to use a custom moc?

---

<div class="post-metadata">

**Author:** ![claudio](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/claudio/32/322_2.png) [@claudio](https://forum.dfinity.org/u/claudio)\
**Post date:** [March 7, 2022, 5:45pm UTC](https://forum.dfinity.org/t/persistent-stable-interface-compatibility-check-failed-error/11281/13 "2022-03-07T17:45:11Z")

</div>

I’m just guessing, but I think you download the new moc binaries and then try

```auto
export DFX_MOC_PATH=<path to new moc>

```

and then use dfx as before.

Update:

I just tried (in a new dfx project)

```auto
export DFX_MOC_PATH=/home/crusso/motoko/bin/moc
dfx deploy 

```

‘/home/crusso/motoko/bin/moc’ is where my locally built moc lives and it worked fine.  
You might have to make the `moc` you download executable first.

(Related post: [DFX deploy with custom Motoko version](https://forum.dfinity.org/t/dfx-deploy-with-custom-motoko-version/7665))

---

<div class="post-metadata">

**Author:** ![jzxchiang](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/jzxchiang/32/2592_2.png) [@jzxchiang](https://forum.dfinity.org/u/jzxchiang)\
**Post date:** [March 7, 2022, 10:17pm UTC](https://forum.dfinity.org/t/persistent-stable-interface-compatibility-check-failed-error/11281/14 "2022-03-07T22:17:52Z")

</div>

AFK right now, but I’ll try again with 0.6.25 tonight!

---

<div class="post-metadata">

**Author:** ![jzxchiang](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/jzxchiang/32/2592_2.png) [@jzxchiang](https://forum.dfinity.org/u/jzxchiang)\
**Post date:** [March 8, 2022, 7:38am UTC](https://forum.dfinity.org/t/persistent-stable-interface-compatibility-check-failed-error/11281/15 "2022-03-08T07:38:15Z")

</div>

So the good news is that `dfx build` now succeeds without error.

But `dfx deploy` still shows the original error even when I make no changes to my stable variable interface:

```auto
Installing canisters...
WARNING!
Stable interface compatibility check failed for canister 'service'.
Upgrade will either FAIL or LOSE some stable variable data.

/Users/justinchiang/yelp2/.dfx/local/canisters/service/service.old.most:19.10-19.11: syntax error [M0001], unexpected token '/', expected one of token or <phrase> sequence:
  = <typ>
  < seplist(<typ_bind>,,) > = <typ>

Do you want to proceed? yes/No
No
Error: Refusing to install canister without approval

```

And line 19 of `service.old.most` is still the same line:

```auto
type Char/2 = Char/1;

```

---

<div class="post-metadata">

**Author:** ![claudio](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/claudio/32/322_2.png) [@claudio](https://forum.dfinity.org/u/claudio)\
**Post date:** [March 8, 2022, 8:29am UTC](https://forum.dfinity.org/t/persistent-stable-interface-compatibility-check-failed-error/11281/16 "2022-03-08T08:29:26Z")

</div>

Great, thanks for helping out!

Right, but I think that makes sense if the deployed version was built with the buggy compiler and contains an ill-formed stable-types section. The dfx deploy will try to parse the old.most as well as the new.most, but old.most is still broken.

I expect that if you click through and do the upgrade, the next upgrade, with both old and new code built by non-buggy compiler, should work without error or click thru warning.

---

<div class="post-metadata">

**Author:** ![claudio](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/claudio/32/322_2.png) [@claudio](https://forum.dfinity.org/u/claudio)\
**Post date:** [March 8, 2022, 7:24pm UTC](https://forum.dfinity.org/t/persistent-stable-interface-compatibility-check-failed-error/11281/17 "2022-03-08T19:24:29Z")

</div>

> I expect that if you click through and do the upgrade, the next upgrade, with both old and new code built by non-buggy compiler, should work without error or click thru warning.

Let me know if that resolves the error. If so, I think we are good to go with this version of moc.

---

<div class="post-metadata">

**Author:** ![jzxchiang](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/jzxchiang/32/2592_2.png) [@jzxchiang](https://forum.dfinity.org/u/jzxchiang)\
**Post date:** [March 9, 2022, 7:04am UTC](https://forum.dfinity.org/t/persistent-stable-interface-compatibility-check-failed-error/11281/18 "2022-03-09T07:04:00Z")

</div>

Ah gotcha, so the old.most file is generated after I click “yes” and not before…

Yep, the error goes away now when I run `dfx deploy` with 0.6.25. But when I run `dfx deploy` with the currently released version of moc, the error returns (as expected).

Just to confirm, I made a small stable-incompatible change to one of my types (i.e. made an immutable field mutable), and when I ran it with 0.6.25 I get this error:

```auto
(unknown location): Compatibility error [M0170], stable variable shops of previous type
  var
   {
     #branch : Branch<ShopId, ShopInfo>;
     #empty;
     #leaf : Leaf<ShopId, ShopInfo>
   }
cannot be consumed at new type
  var
   {
     #branch : Branch __1<ShopId__ 1, ShopInfo__1>;
     #empty;
     #leaf : Leaf __1<ShopId__ 1, ShopInfo__1>
   }

```

It makes sense that I get this error, but how do I actually debug what `ShopId __1` and `ShopInfo__ 1` are? If the old.most file hasn’t been generated yet, does that mean there’s no way for me to dig deeper into the type error?

---

<div class="post-metadata">

**Author:** ![claudio](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/claudio/32/322_2.png) [@claudio](https://forum.dfinity.org/u/claudio)\
**Post date:** [March 9, 2022, 8:21am UTC](https://forum.dfinity.org/t/persistent-stable-interface-compatibility-check-failed-error/11281/19 "2022-03-09T08:21:35Z")

</div>

Thanks again!

The stable-types custom section/’.most’ file is stored in the canisters wasm and generated by the compiler that produced the wasm.

Dfx deploy merely reads the sections from the new and old canisters and calls ‘moc - -stable-compatible’ to compare them. After a compiler upgrade, this means you might be checking compatibility between stable types signature produced by different compiler versions. In this case, one that produced ill-formed signatures ( and one that (hopefully) now does not.

Good point about debugging. Hopefully dfx leaves the files on the filesystem somewhere otherwise the user will need to recreate them by querying the IC, examining the wasm or running ‘moc - - stable-types’ …

---

<div class="post-metadata">

**Author:** ![cryptoschindler](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/cryptoschindler/32/26_2.png) [@cryptoschindler](https://forum.dfinity.org/u/cryptoschindler)\
**Post date:** [March 9, 2022, 12:51pm UTC](https://forum.dfinity.org/t/persistent-stable-interface-compatibility-check-failed-error/11281/20 "2022-03-09T12:51:36Z")

</div>

can those flags be documented please?

[Next page](https://forum.dfinity.org/t/persistent-stable-interface-compatibility-check-failed-error/11281.md?page=2)
