You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
cdktn-cli: Invoke Terraform CLI with node:child_process instead of node-pty. (Bun + Deno support) #4
This should heavily reduce maintenance requirements by dropping node-pty (has native components. CDKTF maintained a fork to pre-compile for 200+ platforms) in favor of node:child_process.
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
Reacted by Simon Heather, Laura Vuorenoja, Matej Spiller Muys and so0k
changed the title [-]`cdktf-cli`: Invoke Terraform CLI with `node:child_process` instead of `node-pty`. (Bun + Deno support)[/-][+]`cdktn-cli`: Invoke Terraform CLI with `node:child_process` instead of `node-pty`. (Bun + Deno support)[/+]on Jan 13, 2026
hashicorp/terraform-cdk#1955 (comment) in particular mentions needed to have an interactive session with the terraform cli for accessing Terraform Cloud.
The pre-built version was added with the same PR with a note of needing to add it for Windows support.
There was some mention of possible changes to Terraform itself to provide better support. Should investigate that further since perhaps a PTY/TTY terminal is no longer required. If it is still required, moving away could be rather challenging.
The originating CDKTF issue I linked notes that node:child_process.spawn() has a stdio: 'inherit' option which seems like it lets a Node.js process control an interactive child process (e.g. Terraform/OpenTofu CLI).
Ideally cdk-terrain could do something like this:
// Works with Node.js or any runtime with Node.js polyfills (e.g. Bun, Deno).import{spawn}from"node:child_process";/* https://developer.hashicorp.com/terraform/cdktf/create-and-deploy/environment-variables Default to 'opentofu' or 'terraform' if not specified.*/tf_binary_name=process.env.TERRAFORM_BINARY_NAME||'opentofu';spawn(tf_binary_name,['apply'],{stdio: 'inherit'});// Wait for confirmation prompt on stdout...process.stdin.write('yes\n');
Dropping node-pty-prebuilt-multiarch isn't just about not maintaining pre-built binaries.
Pre-built binaries are fundamentally a bad experience with things like mismatched C standard library versions (glibc, musl) and hardcoded dynamic linker paths (painful on some operating systems like NixOS and Guix).
The original CDKTF issue elaborates on this much further.
This is using a minimal Nix shell in the nixos/nix container (see the readme for details).
$ just build
# Install JavaScript dependencies.
bun install
bun install v1.3.8 (b64edcb4)
+ @tsconfig/bun@1.0.10
+ @tsconfig/strictest@2.0.8
+ @types/node@22.19.15
+ cdktn-cli@0.23.0-pre.17
+ typescript@5.9.3
+ @cdktn/provider-aws@23.6.0
+ cdktn@0.23.0-pre.17
+ confbox@0.2.4
+ constructs@10.6.0
787 packages installed [15.53s]
# Format.if [[ -z"${CI:-}" ]];then treefmt;else treefmt --fail-on-change;fi
traversed 27 files
emitted 17 files for processing
formatted 0 files (0 changed) in 13ms
# Lint JavaScript files.if [[ -z"${CI:-}" ]];then oxlint --fix;else oxlint;fi
⚠ eslint-plugin-unicorn(no-empty-file): Empty files are not allowed.
╭─[src/[service]/[stage].ts:1:1]
1 │ // ⛔ There should be no stage stratum resources.
· ──────────────────────────────────────────────────
╰────
help: Delete this file or add some code to it.
Found 1 warning and 0 errors.
Finished in 28ms on 6 files with 90 rules using 12 threads.
# Type check JavaScript files.
bun run tsc
# Remove build artifacts.
rm -rf build
# Synthesize templates.
bun run cdktn synthesize --quiet
Could not run version check - Command failed: npm view cdktf-cli version
/bin/sh: line 1: npm: command not found
Usage Error: Node.js version could not be determined
error: "cdktn" exited with code 1
error: Recipe `synthesize` failed on line 30 with exit code 1
DISABLE_VERSION_CHECK=true (i.e. DISABLE_VERSION_CHECK=true bun run cdktn synthesize --quiet) doesn't seem to fix it either since that's for library version checks.
$ just build
# Install JavaScript dependencies.
bun install
bun install v1.3.8 (b64edcb4)
Checked 396 installs across 397 packages (no changes) [68.00ms]
# Format.if [[ -z"${CI:-}" ]];then treefmt;else treefmt --fail-on-change;fi
traversed 27 files
emitted 17 files for processing
formatted 0 files (0 changed) in 18ms
# Lint JavaScript files.if [[ -z"${CI:-}" ]];then oxlint --fix;else oxlint;fi
⚠ eslint-plugin-unicorn(no-empty-file): Empty files are not allowed.
╭─[src/[service]/[stage].ts:1:1]
1 │ // ⛔ There should be no stage stratum resources.
· ──────────────────────────────────────────────────
╰────
help: Delete this file or add some code to it.
Found 1 warning and 0 errors.
Finished in 23ms on 6 files with 90 rules using 12 threads.
# Type check JavaScript files.
bun run tsc
# Remove build artifacts.
rm -rf build
# Synthesize templates.
DISABLE_VERSION_CHECK=true bun run cdktn synthesize --quiet
Usage Error: Node.js version could not be determined
error: "cdktn" exited with code 1
error: Recipe `synthesize` failed on line 30 with exit code 1
IMO these runtime and library version checks shouldn't exist to begin with. That information is supposed to be in any package dependency declarations (e.g. engines + dependencies in package.json, requires-python + dependencies in pyproject.toml, maven.compiler.target + maven.compiler.source + dependencies in pom.xml) and enforced by package managers.
I'm going to lock this issue because it has been closed for 30 days. This helps our maintainers find and focus on the active issues. If you've found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.
Activity
so0k commentedon Jan 13, 2026
[-]`cdktf-cli`: Invoke Terraform CLI with `node:child_process` instead of `node-pty`. (Bun + Deno support)[/-][+]`cdktn-cli`: Invoke Terraform CLI with `node:child_process` instead of `node-pty`. (Bun + Deno support)[/+]jsteinich commentedon Mar 5, 2026
I traced back the addition of
node-ptyto hashicorp/terraform-cdk#1955.hashicorp/terraform-cdk#1955 (comment) in particular mentions needed to have an interactive session with the terraform cli for accessing Terraform Cloud.
The pre-built version was added with the same PR with a note of needing to add it for Windows support.
There was some mention of possible changes to Terraform itself to provide better support. Should investigate that further since perhaps a PTY/TTY terminal is no longer required. If it is still required, moving away could be rather challenging.
so0k commentedon Mar 5, 2026
we could also consider TerraConstructs/terraform-cdk#5 (comment)
use the maintained @homebridge/node-pty-prebuilt-multiarch
or see if opentofu has these issues 😁
commiterate commentedon Mar 5, 2026
The originating CDKTF issue I linked notes that
node:child_process.spawn()has astdio: 'inherit'option which seems like it lets a Node.js process control an interactive child process (e.g. Terraform/OpenTofu CLI).Ideally cdk-terrain could do something like this:
Dropping node-pty-prebuilt-multiarch isn't just about not maintaining pre-built binaries.
Pre-built binaries are fundamentally a bad experience with things like mismatched C standard library versions (glibc, musl) and hardcoded dynamic linker paths (painful on some operating systems like NixOS and Guix).
The original CDKTF issue elaborates on this much further.
so0k commentedon Apr 2, 2026
this is merged and released in this tag @commiterate https://www.npmjs.com/package/cdktn/v/0.23.0-pre.15 if anyone wants to test it?
commiterate commentedon Apr 5, 2026
@so0k commiterate/test-cdktn-bun@617135a
This is using a minimal Nix shell in the
nixos/nixcontainer (see the readme for details).I think this is from https://github.com/open-constructs/cdk-terrain/blob/v0.23.0-pre.17/packages/cdktn-cli/src/bin/cmds/helper/check-environment.ts#L53-L56.
DISABLE_VERSION_CHECK=true(i.e.DISABLE_VERSION_CHECK=true bun run cdktn synthesize --quiet) doesn't seem to fix it either since that's for library version checks.IMO these runtime and library version checks shouldn't exist to begin with. That information is supposed to be in any package dependency declarations (e.g.
engines+dependenciesinpackage.json,requires-python+dependenciesinpyproject.toml,maven.compiler.target+maven.compiler.source+dependenciesinpom.xml) and enforced by package managers.commiterate commentedon Apr 12, 2026
@so0k Should we open a separate issues for the remaining Node.js dependencies and version checks?
jsteinich commentedon Apr 14, 2026
@commiterate we should definitely make a separate issue for tracking making compatible with alternative runtimes.
commiterate commentedon Apr 14, 2026
Done: #106
github-actions commentedon May 14, 2026
I'm going to lock this issue because it has been closed for 30 days. This helps our maintainers find and focus on the active issues. If you've found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.