# PackageId hash changes without Daml code change

**URL:** <https://forum.canton.network/t/packageid-hash-changes-without-daml-code-change/6073>\
**Category:** App Development\
**Tags:** daml, daml-sdk\
**Created:** [February 6, 2023, 2:18am UTC](https://forum.canton.network/t/packageid-hash-changes-without-daml-code-change/6073 "2023-02-06T02:18:30Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Judy\_Wu](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/judy_wu/32/3536_2.png) [@Judy\_Wu](https://forum.canton.network/u/Judy_Wu)\
**Post date:** [February 6, 2023, 2:18am UTC](https://forum.canton.network/t/packageid-hash-changes-without-daml-code-change/6073/1 "2023-02-06T02:18:30Z")

</div>

We bumped into an issue of packageId hash changes non-deterministically when we did not change any daml codes (no changes to daml.yaml file and no changes to any .daml file)

---

<div class="post-metadata">

**Author:** ![Judy\_Wu](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/judy_wu/32/3536_2.png) [@Judy\_Wu](https://forum.canton.network/u/Judy_Wu)\
**Post date:** [February 6, 2023, 2:24am UTC](https://forum.canton.network/t/packageid-hash-changes-without-daml-code-change/6073/2 "2023-02-06T02:24:16Z")

</div>

We later on figured out that this is because we have the -j flag on when doing daml build

```haskell
daml build -j 

```

As specified by the docs

```haskell
The number of threads to run in parallel. 
When -j is not passed, 1 thread is used. 
If -j is passed, the number of threads defaults to the number of number of threads to N. 
Note that the output is not deterministic for > 1 job.

```

Important and painful takeaway for me: packageId only remains the same if we have -j = 1 (or simply don’t add the flag in, default -j is 1) and there’s no changes in .daml files and daml.yaml file.  
Hope this will help anyone that is scratching their head over the same issue.

---

<div class="post-metadata">

**Author:** ![rikotacards](https://avatars.discourse-cdn.com/v4/letter/r/f0a364/32.png) [@rikotacards](https://forum.canton.network/u/rikotacards)\
**Post date:** [February 6, 2023, 2:29am UTC](https://forum.canton.network/t/packageid-hash-changes-without-daml-code-change/6073/3 "2023-02-06T02:29:10Z")

</div>

Interesting find, thanks for posting the solution!

---

<div class="post-metadata">

**Author:** ![Stephen](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/stephen/32/102_2.png) [@Stephen](https://forum.canton.network/u/Stephen)\
**Post date:** [February 6, 2023, 3:29pm UTC](https://forum.canton.network/t/packageid-hash-changes-without-daml-code-change/6073/4 "2023-02-06T15:29:04Z")

</div>

I would also recommend including package ID extraction as part of the build process. For example, the `create-daml-app` and `quickstart-java` we supply work like this:

1. build daml dars
2. generate TypeScript/Java code from the dars, including package ID
3. compile hand-written TypeScript/Java code against that generated code, hence using the package ID that was just built

For cross-project dependencies, `data-dependencies` are the best choice to preserve package ID stability.

Only adding this to say that there is a range of solutions to this issue, and different projects will find different ones to be appropriate.

---

<div class="post-metadata">

**Author:** ![Matteo\_Limberto](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/matteo_limberto/32/2823_2.png) [@Matteo\_Limberto](https://forum.canton.network/u/Matteo_Limberto)\
**Post date:** [February 7, 2023, 8:34am UTC](https://forum.canton.network/t/packageid-hash-changes-without-daml-code-change/6073/5 "2023-02-07T08:34:28Z")

</div>

> [@Stephen](#):
>
> For cross-project dependencies, `data-dependencies` are the best choice to preserve package ID stability.

Hi @Stephen,

Could you elaborate a bit on what guarantees `data-dependencies` offer compared to `dependencies`?

Thanks

---

<div class="post-metadata">

**Author:** ![Stephen](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/stephen/32/102_2.png) [@Stephen](https://forum.canton.network/u/Stephen)\
**Post date:** [February 7, 2023, 2:56pm UTC](https://forum.canton.network/t/packageid-hash-changes-without-daml-code-change/6073/6 "2023-02-07T14:56:55Z")

</div>

The “cut the Gordian knot” way to preserve package ID is to use a distributed prebuilt binary. Can’t get multiple package IDs if you’re always using exactly one prebuilt package, after all.

`data-dependencies` fix

1. the SDK upgrade problem with this strategy – you can use deps built with older SDK versions in new projects
2. the distribution problem – you don’t need an out-of-band dar distribution mechanism to fetch a data-dependency, you can use the ledger
3. relatedly, the “lost library” problem – if upstream loses or has trouble reproducing a dar, it doesn’t matter, because if the templates/data types are in use, the correct dalfs must be on a relevant ledger
