Build dar file (It is a member of the hidden package)

My daml project wants to depend on a dar4 package. This dar4 package itself also depends on three other dar packages, dar1, dar2, and dar3. When I add them all to the dependencies, the project can be built successfully, but I think them repeated dependencies, I want to depend on only one dar4 should contain all dar, but there will be an error
" It is a member of the hidden package"

this can build success but have some warning

sdk-version: 2.6.3
name: hkjc-daml-bet
version: 0.1.0
source: daml
dependencies:
- daml-prim
- daml-stdlib
- daml-script
data-dependencies:
 - ../../../../txn-ledger/bet-daml/.daml/dist/txn-3.1.7.dar
 - ../../../../txn-ledger/itrls-cpc/commingle/cpc-daml/dar/wagering-event-product-management.dar
 - ../../../../txn-ledger/bet-daml/dar/product-engine-validation.dar
 - ../../../../txn-ledger/bet-daml/dar/cpc-partner-management.dar

start-navigator: true
codegen:
  js:
    output-directory: ui/daml.js
    npm-scope: daml.js
# Remove this line when running against a ledger without user management.
init-script: Setup:setup
File:     daml/Setup.daml
Hidden:   no
Range:    16:1-16:30
Source:   typecheck
Severity: DsWarning
Message:
  daml/Setup.daml:16:1: warning:
  The import of ?î„ŠageringEvent.Dividend??is redundant
  except perhaps to import instances from ?î„ŠageringEvent.Dividend??  To import instances alone, use: import WageringEvent.Dividend()
File:     daml/Setup.daml
Hidden:   no
Range:    17:1-17:26
Source:   typecheck
Severity: DsWarning
Message:
  daml/Setup.daml:17:1: warning:
  The import of ?î„ŠageringEvent.Race??is redundant
  except perhaps to import instances from ?î„ŠageringEvent.Race??  To import instances alone, use: import WageringEvent.Race()
File:     daml/Setup.daml
Hidden:   no
Range:    18:1-18:28
Source:   typecheck
Severity: DsWarning
Message:
  daml/Setup.daml:18:1: warning:
  The import of ?î„ŠageringEvent.Status??is redundant
  except perhaps to import instances from ?î„ŠageringEvent.Status??  To import instances alone, use: import WageringEvent.Status()

2023-06-02 09:26:33.10 [INFO]  [build]
Created .daml\dist\hkjc-daml-bet-0.1.0.dar
PS D:\itrls-lp-unbackS33\hkjc-wpp-lpm\prize-fulfillment\daml\payout-template>

I change daml.yml to this will build fail

sdk-version: 2.6.3
name: hkjc-daml-bet
version: 0.1.0
source: daml
dependencies:
- daml-prim
- daml-stdlib
- daml-script
data-dependencies:
 - ../../../../txn-ledger/bet-daml/.daml/dist/txn-3.1.7.dar
#  - ../../../../txn-ledger/itrls-cpc/commingle/cpc-daml/dar/wagering-event-product-management.dar
#  - ../../../../txn-ledger/bet-daml/dar/product-engine-validation.dar
#  - ../../../../txn-ledger/bet-daml/dar/cpc-partner-management.dar

start-navigator: true
codegen:
  js:
    output-directory: ui/daml.js
    npm-scope: daml.js
# Remove this line when running against a ledger without user management.
init-script: Setup:setup

2023-06-02 09:29:21.20 [INFO]  [build]
Compiling hkjc-daml-bet to a DAR.
File:     daml/Setup.daml
Hidden:   no
Range:    8:8-8:19
Source:   not found
Severity: DsError
Message:
  Could not load module ?î„€ain.Racing??  It is a member of the hidden package ?î„Łroduct-engine-validation-2.1.2??
  You can run ??set -package product-engine-validation??to expose it.
  (Note: this unloads all the modules in the current scope.)
File:     daml/Setup.daml
Hidden:   no
Range:    9:8-9:36
Source:   not found
Severity: DsError
Message:
  Could not load module ?î„€ain.ProductEngineValidation??  It is a member of the hidden package ?î„Łroduct-engine-validation-2.1.2??
  You can run ??set -package product-engine-validation??to expose it.
  (Note: this unloads all the modules in the current scope.)
File:     daml/Setup.daml
Hidden:   no
Range:    10:8-10:25
Source:   not found
Severity: DsError
Message:
  Could not load module ?artnerManagement??  It is a member of the hidden package ?î„–pc-daml-0.1.6??
  You can run ??set -package cpc-daml??to expose it.
  (Note: this unloads all the modules in the current scope.)
File:     daml/Setup.daml
Hidden:   no
Range:    11:8-11:38
Source:   not found
Severity: DsError
Message:
  Could not load module ?roductManagement.ProductModel??  It is a member of the hidden package ?î„Șagering-event-product-management-1.0.0.8??
  You can run ??set -package wagering-event-product-management??to expose it.
  (Note: this unloads all the modules in the current scope.)
File:     daml/Setup.daml
Hidden:   no
Range:    12:8-12:29
Source:   not found
Severity: DsError
Message:
  Could not load module ?î„ŠageringEvent.Meeting??  It is a member of the hidden package ?î„Șagering-event-product-management-1.0.0.8??
  You can run ??set -package wagering-event-product-management??to expose it.
  (Note: this unloads all the modules in the current scope.)
File:     daml/Setup.daml
Hidden:   no
Range:    13:8-13:28
Source:   not found
Severity: DsError
Message:
  Could not load module ?î„ŠageringEvent.Runner??  It is a member of the hidden package ?î„Șagering-event-product-management-1.0.0.8??
  You can run ??set -package wagering-event-product-management??to expose it.
  (Note: this unloads all the modules in the current scope.)
File:     daml/Setup.daml
Hidden:   no
Range:    14:8-14:26
Source:   not found
Severity: DsError
Message:
  Could not load module ?î„ŠageringEvent.Pool??  It is a member of the hidden package ?î„Șagering-event-product-management-1.0.0.8??
  You can run ??set -package wagering-event-product-management??to expose it.
  (Note: this unloads all the modules in the current scope.)
File:     daml/Setup.daml
Hidden:   no
Range:    15:8-15:33
Source:   not found
Severity: DsError
Message:
  Could not load module ?î„ŠageringEvent.Combination??  It is a member of the hidden package ?î„Șagering-event-product-management-1.0.0.8??
  You can run ??set -package wagering-event-product-management??to expose it.
  (Note: this unloads all the modules in the current scope.)
File:     daml/Setup.daml
Hidden:   no
Range:    16:8-16:30
Source:   not found
Severity: DsError
Message:
  Could not load module ?î„ŠageringEvent.Dividend??  It is a member of the hidden package ?î„Șagering-event-product-management-1.0.0.8??
  You can run ??set -package wagering-event-product-management??to expose it.
  (Note: this unloads all the modules in the current scope.)
File:     daml/Setup.daml
Hidden:   no
Range:    17:8-17:26
Source:   not found
Severity: DsError
Message:
  Could not load module ?î„ŠageringEvent.Race??  It is a member of the hidden package ?î„Șagering-event-product-management-1.0.0.8??
  You can run ??set -package wagering-event-product-management??to expose it.
  (Note: this unloads all the modules in the current scope.)
File:     daml/Setup.daml
Hidden:   no
Range:    18:8-18:28
Source:   not found
Severity: DsError
Message:
  Could not load module ?î„ŠageringEvent.Status??  It is a member of the hidden package ?î„Șagering-event-product-management-1.0.0.8??
  You can run ??set -package wagering-event-product-management??to expose it.
  (Note: this unloads all the modules in the current scope.)
ERROR: Creation of DAR file failed.

what should i do better

Hi @skylorna,

You seem to be confusing packages, dars, and modules.

As a quick recap:

  • A module is essentially a single file that contains daml code. At the module/file level, you can have fairly granular control over what you expose and what you keep private to the module. You also have to explicitly import other modules if you want to use the things they export.
  • A package is the result of compiling a single daml project, which will generally be composed of multiple modules/files, and will generally depend on other projects/packages. A compiled package is a dalf file.
  • A dar file is essentially a zip file that contains a “main” package dalf along with all of its dependencies.

Dalfs are named by a hash of their content, so having multiple “copies” of the same dalf is harmless. The underlying code will be loaded only one and there is no risk of overwriting code with another definition.

In your case, the error message you’re seeing is not at the package level, though. Your issue is not with the code you’re loading as part of the project definition, but it is with the import declarations.

Specifically, the error message is telling you that you are importing a type, and then not using it. So instead of tweaking your data-dependencies in daml.yaml, if you want to get rid of that error message you’ll need to tweak your import statements in the daml/Setup.daml file.

I’d need to see the file to be sure, but it’s probably going to be something like replacing

import WageringEvent.Compination
import WageringEvent.Dividend
import WageringEvent.Race
import WageringEvent.Status

with (note the parentheses):

import WageringEvent.Compination()
import WageringEvent.Dividend()
import WageringEvent.Race()
import WageringEvent.Status()

Hope that helps. If not, please share your Setup.daml file.

I update the Setup.daml,but have same error
image

The error message is like this

Could not load module ‘Main.Racing’
It is a member of the hidden package ‘product-engine-validation-2.1.2’.
You can run ‘:set -package product-engine-validation’ to expose it.
(Note: this unloads all the modules in the current scope.)not found

Originally there were no parentheses,

What is the state of your daml.yaml file at this point?

this is my daml.yaml

sdk-version: 2.6.3
name: hkjc-daml-bet
version: 0.1.0
source: daml
dependencies:
- daml-prim
- daml-stdlib
- daml-script
data-dependencies:
 - ../../../../txn-ledger/bet-daml/.daml/dist/txn-3.1.7.dar
#  - ../../../../txn-ledger/itrls-cpc/commingle/cpc-daml/dar/wagering-event-product-management.dar
#  - ../../../../txn-ledger/bet-daml/dar/product-engine-validation.dar
#  - ../../../../txn-ledger/bet-daml/dar/cpc-partner-management.dar

start-navigator: true
codegen:
  js:
    output-directory: ui/daml.js
    npm-scope: daml.js
# Remove this line when running against a ledger without user management.
init-script: Setup:setup

You need to revert your changes, i.e. uncomment the data-dependencies.

1 Like

Thank you, now there are no errors or warnings