Why different dependency ids in for same dependency in different apps?

I two almost identical apps and sometimes I pull to my computer and copy a form or a module from one app to the other. Everything works fine with the exception of some MultiSelectDropdowns (from Anvil Extras) that break because in one app they are referred as type: form:dep_i0spdzp3v8wvw:MultiSelectDropDown and in the other as type: form:dep_d719rff5niregq:MultiSelectDropDown.

The workaround is easy: after copying the whole form, replace the id on each instance of each MultiSelectDropDown.

In anvil.yaml I can see a difference in how the dependency is defined:

- dep_id: dep_i0spdzp3v8wvw
  resolution_hints: {app_id: C6ZZPAPN4YYF5NVJ, name: Anvil Extras, package_name: anvil_extras}
  version: {version_tag: v2.7.1}

- dep_id: dep_d719rff5niregq
  resolution_hints: {app_id: C6ZZPAPN4YYF5NVJ, name: Anvil Extras, package_name: anvil_extras}
  version: {version_tag: v2.7.1}

I would like to understand why it works as it does and if I have done anything wrong that caused this discrepancy.

1 Like

A bit too much information:

a dep_id is a handle we store in the database for your app. In the database the dep_id links to a dependency’s app id.
Since the dependency’s app id is only in the database and not the source code, it allows us to re-target a dependency without affecting the source code.

What you can do

If you change the dep_id in the source code of AppA to match the dep_id in AppB.
(note you’ll need to do this for every occurrence of dep_i0spdzp3v8wvw)

This will lead to an error in the Dependency settings, that looks like the following:

Screenshot 2024-10-12 at 00.41.30

That’s because there is nothing in our database for this new dep_id

To resolve this:

  • Click the edit icon
  • Select the right dependency

And now the dep_id is associated with the right app in the database :trophy:

Allowing you to happily copy and paste, without having to change the yaml again.

4 Likes

And since this id is per-App, you can retarget one App’s dependency without affecting any other Apps.

1 Like