Skip to content
Discussions/App Development/Problem with transitive dependenciesForum ↗

Problem with transitive dependencies

App Development10 posts732 views4 likesLast activity Mar 2022
LU
LucianoOP
Mar 2022

I have the following daml.yaml file under src/:

source: src/test/daml
data-dependencies:
  - lib/contingent-claims-2.0.0.dar
#  - lib/daml-ctl-2.0.0.dar
build-options:
  - --include=src/main/daml

The commented out dependency is a transitive dependency via contingent-claims, which I want to use. However, if I uncomment that line, and try to import form daml-ctl, I see

./main/daml/**/*.daml|16 col 8| not found:Error:Could not load module ‘Daml.Control.Monad.Trans.Class’ It is a member of the hidden package ‘daml-ctl-2.0.0’. You can run ‘:set -package daml-ctl’ to expose it. (Note: this unloads all the modules in the current scope.)

I’ve seen this error before in the linked post See also Module ‘Daml.Script’ It is a member of the hidden package ‘daml-script-1.10.0’, but to my understanding this was to a bad directory hierarchy. Why is it happening in this case? How can I use the transitive dependency in the project?

AK
akrmn
Mar 2022

Hi @Luciano, this is to be expected. In general it is only allowed to import modules from direct dependencies. The error message is a bit misleading, but the important part is that the package ‘daml-ctl-2.0.0’ is “hidden” because it’s not a direct dependency (regardless of it being a transitive dependency). This is true for both regular and data- dependencies, and it’s inherited from GHC.

In this case, I’d suggest simply uncommenting that line, but I’d like to understand your motivation for removing it.

CO
cocreature
Mar 2022

You can also manually expose transitive deps by adding --package flags, e.g.,

build-options:
  - --package=nameofdep-versionofdep
CO
cocreature
Mar 2022

As for why we don’t expose transitive deps by default: Only exposing direct deps limits module collisions to a minimum and therefore the modules you might have to rename. E.g., an older stdlib is usually not in scope so you don’t have to worry about renaming modules from it to avoid a collision unless you truly need a direct reference to the old stdlib.

LU
Luciano
Mar 2022
akrmn:

because it’s not a direct dependency

Even if I include it explicitly in the daml.yaml file (I.e. uncomment it above)?

CO
cocreature
Mar 2022
Luciano:

Even if I include it explicitly in the daml.yaml file (I.e. uncomment it above)?

Then it becomes a direct dependency and it should work.

LU
Luciano
Mar 2022

Nope. I restarted the IDE and everything …

CO
cocreature
Mar 2022

Can you share a minimal example to reproduce this?

LU
Luciano
Mar 2022

Hey @akrmn I thought you had posted here that sometimes clearing the build directory helped. It turned out in this case to be a combination of this, and the fact that I initialized the language server from the wrong directory (src/main instead of src). Restarting the IDE seems to have helped.

CO
cocreature
Mar 2022

I usually recommend first trying to reproduce weird dependency issues with daml build. I’m not actually aware of any cases where you currently need to daml clean so if you are, I’d be interested in examples.

← Back to Discussions