cdktf-cli: Support non-global installs (and report a correct error message if not supported)
Description
In order to minimize "it works on my machine" type errors, we have a policy of not globally installing helper tools. We use NVM to ensure our node-version is correct within every project. And we use yarn to access locally installed binaries without hardcoding paths.
Unfortunately, cdktf-cli init throws an error when executed within a local-install / yarn context.
$ yarn cdktf init --template=typescript --providers=kreuzwerker/docker --local
(node:35155) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
ERROR: Cannot initialize a project in a non-empty directory
This ERROR goes away if you globally install it and run the same command (without yarn) in the same directory.
Even if you don't support the feature request, this is an incorrect or at least very confusing error message for this condition, so if this ticket gets closed, we should open another one for that issue.
References
- https://github.com/hashicorp/terraform-cdk/issues/1697
- https://github.com/hashicorp/terraform-cdk/issues/2490
Help Wanted
- [ ] I'm interested in contributing a fix myself
Community Note
- Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
- Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
- If you are interested in working on this issue or have submitted a pull request, please leave a comment
Just ran into this myself. This is a baffling restriction.