Why does --project-root not pick up the SDK version of the project?

I ran into this issue with building a DAML project.

While setting DAML_SDK_VERSION does solve the issue I would have expected this to work as well:

daml build --project-root path-to-my-project

However, it picks up the SDK version I have installed globally.


1 Like

This is a bit of an unfortunate consequence of how things are implemented. SDK versions are handled by the assistant which will invoke a tool for a given SDK version (in this case the daml compiler) once the SDK has been installed. However --project-root is handled by the compiler. So by the time we resolve --project-root, we’ve already invoked the compiler binary for a given version.

A way around this is to use the DAML_PROJECT environment variable which is resolved by the assistant itself so it ends up invoking the correct compiler binary.

1 Like

Indeed --project-root is problematic because it can’t pick the correct SDK version. Using the DAML_PROJECT environment variable is the correct way to set the project path when using the daml assistant:

DAML_PROJECT="path-to-my-project" daml build
1 Like