Daml codegen affected by DAML_PROJECT
- Tamas_KalczaOP 1
Seems like setting
DAML_PROJECTaffectsdaml codegenas well, and it seems this is intentional. Why is that? What is missing if I run this command:
daml codegen java --output=java_files an_example.dar - cocreature 1
daml codegen javadefaults to reading the information from thedaml.yamlwhich we locate inDAML_PROJECT. The codegen uses either CLI args orDAML_PROJECTbut not both atm, so in your exampleDAML_PROJECTwon’t be used. - Tamas_Kalcza 1
Assume I am in a valid Daml project. If I issue the following commands:
unset DAML_PROJECT daml build --output=example.dar export DAML_PROJECT=an_unrelated_path daml codegen java --output=java_files example.darthe last command will fail. If I understood you correctly, this should not happen.
The fix in my use case was pretty easy, I was just a bit surprised.
- cocreature 1
Oh sorry, you are right and this is expected. We use
DAML_PROJECTto figure out the SDK version. Otherwise (if you don’t have DAML_SDK_VERSION set) we use whatever SDK version you currently have globally which is rarely what you want and definitely not consistent across developers in your team. - Tamas_Kalcza 1
So specifying the
DAML_SDK_VERSIONwould also work, or usingDAML_PROJECTconsistently (which I did in my case).For education purposes: would it hard/impractical/impossible to figure out the SDK version from the DAR file?

- cocreature 2
Tamas_Kalcza:For education purposes: would it hard/impractical/impossible to figure out the SDK version from the DAR file?
The SDK version is figured out by the assistant before invoking the underlying tool (the codegen in this case). The assistant has no understanding of the command line parameters of the underlying tool (it just passes them through) so it can’t know what refers to a DAR and what doesn’t. The codegen does understand the parameters of course but once the codegen is invoked the SDK version is already fix. The assistant only understands a few environment variables and parts of
daml.yamlso that’s the only thing that affects the SDK version.As for whether the codegen could figure out the SDK version (ignoring whether that would be useful since as mentioned above, it’s too late), you
you can technically get the SDK version a DAR was built with but it’s perfectly reasonable to run a newer codegen against that (and even older codegens assuming they support the lf version) so inferring the SDK version from the DAR isn’t all that useful.