[FIXED] Using app as library is very brittle

Making a small mistake with an app as a library is easy and unrecoverable. The steps below illustrate this behaviour.

Then there is the point of not having a procedure to update dependencies. What should one do if, say, the IFrame component gets updated (even if there is no notification of such a fact)?

1 Like

I agree on the first part of your post: Anvil should tell you that an app is used as a dependency and should not allow you to delete it. And if you manage to delete a dependency (playing around with git offline for example), it should show a more helpful message.

The answer about the second part of your post is that Anvil covers the workflow in simple cases: you can set the dependency to the Development or Published branch of the dependency. Then you know that any change you do to the dependency app will be immediately live with any app that depends on it.

This works fairly well in simple cases, but you can get in trouble in more complex cases. So, as long as you know what you are doing, the system is simple, but works. But I agree with you, sooner or later you find out that it’s brittle.

1 Like

I think you’ve found a bug there.

can’t open an app after its dependency was deleted

I tried your steps and can confirm the same behaviour.


this would be a nice feature. In addition to the usual warning… Something like:

the following app is used as a dependency for: X, Y, Z
Are you sure you want to delete this app?

It makes sense why, since you now have your own copy of the dependency. But there’s no easy way to pull in updates natively with anvil from the app you cloned from.

Re-cloning can be cumbersome. You wouldn’t want to replace the dependency in all the apps that depend on it! And even if you’re a git wizard :mage: recloning every time there is an update :roll_eyes:… no thanks.

In github you would do the following:

  • fork a git hub repo (call it the Base repo)
  • git clone your fork to download it locally
  • add the Base as a remote branch
  • pull changes from the Base remote and push changes to your fork

So maybe a nice feature request would be to:

add an anvil app as a git remote that I don’t own

This would be awesome!

  • clone the Iframe dependency in the usual way (the Base)
    (effectively a fork)
  • use the git clone command to download it locally
  • get the git link from the Base in order to add it as a remote
    (you wouldn’t have permission to push changes only to fetch changes)
  • pull changes from the Base remote and push the changes to your anvil app (the fork)

Even more awesome would be for anvil to abstract away the challenging parts from the above workflow, namely working locally…

Confirmed, the behaviour you’re describing is a bug! Moving to Bug Reports.

1 Like

This is now fixed - thanks for your patience everyone!

4 Likes

That’s quick. I can confirm that I can reopen the Altair app. That’s comforting. Thanks for this.

You are probably aware that the app is still broken because of the missing dependency. Even removing the stale dependency and reinstalling the Iframe component will not fix the app.
Fixing that would require some more work right? :wink:

Once you’ve removed and re-added the dependency, you’ll need to recreate the IFrame component within your app. That’s because Anvil uses the ID of the dependency app to match up dependency components on a form, and you’ve deleted the app that component was originally from! So yes, I’m afraid you’ll need to delete and recreate that component, but you’ll find it works then :slight_smile:

1 Like

Well, that’s what I did. Because I knew that the Altair app uses the Iframe component, I deleted the old dependency and added the Iframe component as a “new” dep (god forbid what happens if you don’t know what the old dep was, the ID is not very useful then). However the Altair app is still broken since the instance of the Iframe also has some ID so the newly added Iframe component will not used. The old Iframe and the new Iframe component are treated as distinct. In this toy program no problem; delete the old instance and add a new instance of Iframe.
But what about a real program? You would have to hunt down all instances of obsolete component instances, guess their properties (since they are not visible anymore) and replace them with new component instances. Talk about a nightmare scenario.

Apologies for the necro, but this does not appear to be fixed for me. https://acnh-fossils.anvil.app/ used HashRouting as a dependency, and after mistakenly deleting the old dependency before creating switching to the new one, the app tells me that App dependency not found - even after checking the app out using git and confirming that every dependency is valid.

I now have no way of accessing this app again (cloning it leaves the issue in the clone too)

Potential solutions I’ve tried:

  • Clone with git, modify anvil.yaml, force push
  • Clone with anvil, run
  • Completely remove HashRouting dependency, add it again

Other notes (in rough order of most-helpful to least-helpful):

  • Dependencies were checked by loading https://anvil.works/build#app:DEPENDENCY_ID with each app_id listed in anvil.yaml -> dependencies - all 4 loaded successfully
  • I was unable to reproduce this error in a new app
  • HashRouting is a ‘libraries-only’ dependency; no components to worry about replacing like meredydd mentioned
  • Prior to deleting the app dependency I did have 2 versions of HashRouting under my account
  • 2 of the 3 other dependencies are also libraries-only (one allows control over the loading spinner, one provides popovers, and the dependency containing components is Tabulator)

Once again sorry for the necro but this thread seemed appropriate

1 Like

Hi @starwort,

Thanks for the details provided. It looks like it’s a dependency-of-a-dependency that’s missing in this case. If you check each of your dependencies for missing dependencies, you should find the problem :slight_smile:

We’re working to surface these errors more clearly so that you can spot this easily if it happens again!

Good spot! I don’t even know why my dependency depended on the old HashRouting since it didn’t even have any forms, lol. Thanks for the help (and for the reassurance that there’ll be an easier dependency detection system!)