I’ve followed the suggestions in How to build dars but not include scenarios? to separate my test scripts by having Test.daml
file as the source
in a custom daml.yaml
in it’s own directory.
But I’m seeing this error now, when doing a daml build
:
/home/luciano/src/da-marketplace/contingent-claims/daml/Test.daml|16 col 8| not found:Error:Could not load module ‘Daml.Script’ It is a member of the hidden package ‘daml-script-1.10.0’. You can run ‘:set -package daml-script’ to expose it. (Note: this unloads all the modules in the current scope.)
Any idea how do fix this? I am running the build from the dir containing the test daml.yaml
file.
For reference, here is the build file:
sdk-version: 1.10.0
name: contingent-claims-test
version: 0.0.1
source: ../daml/Test.daml
init-script: Initialization:createContracts
parties:
- Buyer
- Seller
- Registrar
#exposed-modules:
#- Finance
dependencies:
- daml-prim
- daml-stdlib
- daml-script
1 Like
It looks (based on the source path in your YAML file) like you’re working in a nested Daml project. As far as I know this is not supported at the moment.
$ daml new t
Created a new project in "t" based on the template "skeleton".
$ cd t
$ daml new nested
Target directory is inside existing DAML project "t"
Please specify a new directory outside an existing project.
$
If I nonetheless create the nested project outside of the main one but then move it inside, I do get a similar (but different) error:
$ daml build
Compiling nested to a DAR.
File: ../daml/Main.daml
Hidden: no
Range: 3:8-3:19
Source: not found
Severity: DsError
Message:
Could not find module ‘Daml.Script’
It is not a module in the current program, or in any known package.
ERROR: Creation of DAR file failed.
Even though both the inner and outer projects both have daml-script
as an explicit dependency. I get the same result without nesting, actually, if both projects sit next to each other.
The documentation for the source
field says:
the root folder of your Daml source code files relative to the project root.
It looks to me like the source code has to be within the project folder (i.e. below/next-to the daml.yaml
file itself), but I don’t know enough about the assistant to say whether that’s a bug or intended behaviour. In the latter case it would probably be worth updating the docs page to state that explicitly.
If your issue seems different from what I’ve described here, please provide a bit more context on how to reproduce.
2 Likes
The behavior you’re describing is expected. The ../
stuff doesn’t work if you have dependencies.
I see two solutions:
- If you really want to stick with this approach, symlink so you have the
daml.yaml
be in the parent directory of the source file.
- Alternatively, I’d recommend to just split it into proper packages.
1 Like
Thanks, that solved it. I ended up with this layout:
./daml.yaml
daml
daml/ContingentClaims
test
test/daml.yaml
test/daml
test/daml/ContingentClaims # <-- symlink to line 3
test/daml/Test
1 Like