I ran into this issue with building a DAML project.
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.
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.
--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_PROJECT="path-to-my-project" daml build