Working with packages of different versions

Currently I started to work on a Daml model upgrade facility. This involves having different version of the same package.

What is the recommended way to work with that? This Importing different versions of the same package fails post implies to have two Daml projects for the two versions. Frankly I am not a fan of this. What would be the alternative? Have one project (e.g.: models) and manually build the different versions for example by switching git branches?

Also, I ran into some issues, which raised some questions:

  1. I am happy using the module-prefixes. If I read the docs right I can drop the build-options, right?
  2. It seems I cannot trick the Daml compiler. I manually created the old.dar and new.dar from the same codebase. I got the error: Could not find package new. It sort of makes sense, but is this intentional?
  3. I made a small change and compiled the new.dar, the old remained as is. When I tried to compile the upgrader I got: Transitive dependencies with same unit id but conflicting package ids...

This is how my daml.yaml looks like:

sdk-version: 1.11.1
name: upgrader
version: 1.0.0

source: ./

  - daml-prim
  - daml-stdlib

  - ../build/old.dar
  - ../build/new.dar

  - --package
  - old
  - --package
  - new

  old: Old
  new: New
1 Like

You don’t actually need the project for the old version, you just need the DAR. So an easy but perhaps slightly ugly solution is to simply check in your old DARs. For larger projects you probably want to use Git LFS for this or host them outside of your git repository but the basic idea stays the same. Then current HEAD of your repo only contains the current project and you reference old versions by referencing the corresponding DAR which is either checked in or downloaded from an external repo.

Yes, module-prefixes can act as a full replacement for the --package option.

This is intentional. However, changing the version or changing the name is sufficient for them to no longer be considered identical. I think its also worth pointing out that simply renaming the DAR does not change the package name. The package name is determined according to the name in your daml.yaml and is written at compile time into the Dalf in the DAR.

You have to change the version and/or the name. It is not possible to depend on two different packages with the same name and version. This is the tradeoff we chose for the compiler to avoid users having to specify package ids everywhere.

1 Like