Importing different versions of the same package fails

I’m trying to use the --package build option as per the documentation here to upgrade a contract from one version of a dar to a different version (same package, module and template names).
Hence I have 3 separate projects for this -

  1. PrimerV1 (that builds to Primer-0.0.1.dar)
  2. PrimerV2 (that builds to Primer-0.0.2.dar)
  3. UpgradePrimer (build fails)

Upon executing a daml build on project UpgradePrimer, I get the following error -

Compiling Primer to a DAR.
File:     
Hidden:   no
Range:    1:0-100001:0
Source:   compiler
Severity: DsError
Message: 
  <command line>: cannot satisfy --package Primer-0.0.2 with (Assets.AssetTypes as V2.AssetTypes,
  Managers.CoinManager as V2.Managers)
  (use -v for more information)
ERROR: Creation of DAR file failed.

The daml.yaml for project UpgradePrimer looks like the following -

sdk-version: 1.0.0
name: UpgradePrimer
source: daml
parties:
  - Alice
  - Bob
version: 0.0.1
dependencies:
  - daml-prim
  - daml-stdlib
  - daml-script
build-options:
  - '--package'
  - 'Primer-0.0.1 with (Assets.AssetTypes as V1.AssetTypes, Managers.CoinManager as V1.Managers)'
  - '--package'
  - 'Primer-0.0.2 with (Assets.AssetTypes as V2.AssetTypes, Managers.CoinManager as V2.Managers)'
sandbox-options:
  - --wall-clock-time

The daml.yaml for project PrimerV1 looks like the following -

sdk-version: 1.0.0
name: Primer
source: daml
parties:
  - Alice
  - Bob
version: 0.0.1
dependencies:
  - daml-prim
  - daml-stdlib
  - daml-script
sandbox-options:
  - --wall-clock-time

The daml.yaml for project PrimerV2 looks like the following -

sdk-version: 1.0.0
name: Primer
source: daml
parties:
  - Alice
  - Bob
version: 0.0.2
dependencies:
  - daml-prim
  - daml-stdlib
  - daml-script
sandbox-options:
  - --wall-clock-time

I still have no idea what I am doing, but it seems to me that you never tell daml where to find those DAR files. Looking at an example, it seems like you should add the path to Primer1.dar and Primer2.dar in your data-dependencies.

2 Likes

Thanks @Gary_Verhaegen - adding a data-dependencies tag with the paths to the 2 dars worked for me.