Codegen Java dpm
- austinOP
Hi,
I am on dpm 3.5.4 or version 1.0.21 and I am attempting to generate java bindings for my dar. I went to run
dpm codegen-javaand it seems like that command no longer exists? Was it moved to a different location within dpm?Thanks,
Austin
- Federico_Rodriguez
Hey,
codegenand itscodegen-javacommand, are included in the 3.5.4 bundle.If that is not the case for you, here are a few things to check:
1. Check which DPM is running
which dpm dpm version --active dpm --versionExpected active SDK:
3.5.4.2. Check environment overrides
echo "$DPM_HOME" echo "$DPM_SDK_VERSION" echo "$DPM_REGISTRY" echo "$DPM_EDITION"Watch for
DPM_HOMEpointing somewhere unexpected, orDPM_SDK_VERSIONoverriding the SDK away from3.5.4.3. Check whether the project config overrides SDK components
find .. -name daml.yaml -o -name multi-package.yaml rg -n "sdk-version|components:" daml.yaml multi-package.yaml ../*/daml.yaml ../*/multi-package.yamlIf
components:is present, DPM may ignore the bundled SDK components and only expose explicitly listed components. Make surecodegenis included.4. Check DPM’s resolved component set
dpm resolve --output json | jq '.DefaultSDK, .Packages'For
3.5.4, expect to see:"codegen": { "version": "3.5.2" }5. Check the installed SDK manifest
cat ~/.dpm/cache/sdk/open-source/3.5.4.yamlExpected:
codegen: version: 3.5.26. Check the codegen component itself
cat ~/.dpm/cache/components/codegen/3.5.2/component.yaml ls -l ~/.dpm/cache/components/codegen/3.5.2/binary.jarIn
component.yaml, expect:name: codegen-java7. Try the command directly
dpm codegen-java --helpExpected:
codegen-java 3.5.2 - austin
Hi Federico, thanks for the response! I see everything that you are expecting me to see. However, when I actually run
dpm codegen-javaI getError: unknown command "codegen-java" for "dpm"Run 'dpm --help' for usage.Then when I rundpm helpthere is no codgen-java command visible:dpm help
Usage:
dpm [command]Meta Commands
add Add components and dars to project
install Install project’s dependencies or specific dpm-sdk version
publish Commands for publishing artifacts
tags List published tags of an artifact
uninstall Uninstall a dpm-sdk version
update Update project dependencies
version Show sdk versionsDpm Commands
build Build a Daml package or project
clean Clean a Daml package or project
damlc Compiler and IDE backend for the Daml programming language
docs Generate documentation for a daml package from its documentation comments
inspect-dar Inspect a DAR archive
script Daml Script Binary
studio Launch Daml Studio
test Test the current Daml project or the given files by running all test declarations.
validate-dar Validate a DAR archiveAdditional Commands:
completion Generate the autocompletion script for the specified shell
help Help about any commandFlags:
-h, --help help for dpm
-v, --version version for dpmUse “dpm [command] --help” for more information about a command.
- Federico_Rodriguez
Your
dpm helpoutput is missing more than justcodegen-java. A normal full3.5.4installation should also show commands such as:-
codegen-js -
sandbox -
canton-console -
new -
init -
pqs -
upgrade-check -
daml-shell
The commands you do see mostly come from
damlcplusdaml-script, so DPM is likely resolving a reduced component set in that directory rather than the full bundled3.5.4SDK.1. Check the current directory and environment
Run:
pwd env | sort | grep -E '^(DPM_|DAML_)'In particular, look for any of these variables:
DPM_ASSEMBLY DPM_SDK_VERSION DPM_HOME DAML_PACKAGE DAML_PROJECT DPM_MULTI_PACKAGE2. Check for project-specific components
Run:
find .. -name daml.yaml -o -name multi-package.yaml grep -R "components:" -n daml.yaml multi-package.yaml ../*/daml.yaml ../*/multi-package.yaml 2>/dev/nullIf
components:is present, DPM may be using the explicitly configured components rather than the full SDK bundle.In that case, make sure
codegenis included:components: codegen: version: 3.5.23. Test outside the project
To determine whether this is caused by project-local configuration, try from
/tmp:cd /tmp dpm version --active dpm helpIf
codegen-javais present when running dpm on/tmp, the issue is almost certainly related to the project-local configuration.If it is still not present, please send the output of:
dpm resolve --output json cat ~/.dpm/cache/sdk/open-source/3.5.4.yaml cat ~/.dpm/cache/components/codegen/3.5.2/component.yamlThat should show whether DPM is resolving the expected
3.5.4SDK and whether thecodegencomponent is installed and registered correctly. -
- austin
It seems like the issue was in my multi-package.yaml file with the components! I only had script and damlc listed, I’ve added codegen and it now appears. Thank you! Do you know what would’ve caused version 3.5.2 to have all commands available by default and then 3.5.4 to need codegen explicity listed in the multi-package.yaml? Maybe a config update?
- Federico_Rodriguez
I am not aware of this behavior changing recently. If the project explicitly declares
components, DPM will resolve the component set from that project configuration. If you remove the components field then you should get the full sdk bundle. - austin
Ah ok, I’ll give that a shot. Maybe it has something to do with the fact that I have both dpm 3.5.2 and 3.5.4 installed
- sormeter
yeah if you specify
sdk-versionit will include the full bundle of all the components – which you may or may not needif you want to more closely control and use only the components of interest, you can use the
components:blockthis can be specified at the multi-package.yaml top-level, and will then inherit down to the individual daml.yaml
if you have one value set at the top level (multi package says sdk-version:3.5.2) and a separate value set within a project (daml.yaml says sdk-version:3.5.4), the child daml.yaml value wins
hope this helps