Open ozyman42 opened 9 months ago
There are 2 issues here, both being tracked in other issues:
@Electroid can we keep this open as I think excluding #4798 and #4785, there are still additional issues w/ the cdktf CLI. It is planned within Bun's roadmap to support this package because I plan on working on this if allowed.
I'm running into similar issues with v1.0.2 (Which fixed some of the aws sdk errors) and now I'm getting
Error: Cannot find module '../build/Release/pty.node'
@ConorWright did you mean to post this somewhere else? This ticket is meant for the cdktf-cli
npm package specifically. With v1.0.2 I'm still seeing the error being tracked in #1446
Tried again today w/ bun 1.0.2 and made it past the crash error.
root@f80276d57270:/home/bun/app# bunx cdktf
Please pass a command to cdktf, here are all available ones:
bunx
Commands:
bunx init Create a new cdktf project from a template.
bunx get Generate CDK Constructs for Terraform providers and modules.
bunx convert Converts a single file of HCL configuration to CDK for Terraform. Takes the
file to be converted on stdin.
bunx deploy [stacks...] Deploy the given stacks [aliases: apply]
bunx destroy [stacks..] Destroy the given stacks
bunx diff [stack] Perform a diff (terraform plan) for the given stack [aliases: plan]
bunx list List stacks in app.
bunx login Retrieves an API token to connect to Terraform Cloud or Terraform Enterprise.
bunx synth Synthesizes Terraform code for the given app in a directory.
[aliases: synthesize]
bunx watch [stacks..] [experimental] Watch for file changes and automatically trigger a deploy
bunx output [stacks..] Prints the output of stacks [aliases: outputs]
bunx debug Get debug information about the current project and environment
bunx provider A set of subcommands that facilitates provider management
bunx completion generate completion script
Options:
--version Show version number [boolean]
--disable-plugin-cache-env Dont set TF_PLUGIN_CACHE_DIR automatically. This is useful when the
plugin cache is configured differently. Supported using the env
CDKTF_DISABLE_PLUGIN_CACHE_ENV. [boolean] [default: false]
--log-level Which log level should be written. Only supported via setting the env
CDKTF_LOG_LEVEL [string]
-h, --help Show help [boolean]
Options can be specified via environment variables with the "CDKTF_" prefix (e.g. "CDKTF_OUTPUT")
error: "cdktf" exited with code 1 (SIGHUP)
root@f80276d57270:/home/bun/app# bunx cdktf init
node: symbol lookup error: /root/.bun/install/global/node_modules/@cdktf/node-pty-prebuilt-multiarch/prebuilds/linux-x64/node.abi108.node: undefined symbol: node_module_register
error: "cdktf" exited with code 127
So here we can see a couple issues:
bunx
when it meant to print cdktf
undefined symbol: node_module_register
To solve problem 1 above, I did the following:
cp /usr/local/bin/bun /usr/local/bin/node
Then I got
root@126897ef06e0:/home/bun/app# cdktf -h
cdktf
Commands:
cdktf init Create a new cdktf project from a template.
cdktf get Generate CDK Constructs for Terraform providers and modules.
cdktf convert Converts a single file of HCL configuration to CDK for Terraform. Takes the file to be converted on stdin.
cdktf deploy [stacks...] Deploy the given stacks [aliases: apply]
cdktf destroy [stacks..] Destroy the given stacks
cdktf diff [stack] Perform a diff (terraform plan) for the given stack [aliases: plan]
cdktf list List stacks in app.
cdktf login Retrieves an API token to connect to Terraform Cloud or Terraform Enterprise.
cdktf synth Synthesizes Terraform code for the given app in a directory. [aliases: synthesize]
cdktf watch [stacks..] [experimental] Watch for file changes and automatically trigger a deploy
cdktf output [stacks..] Prints the output of stacks [aliases: outputs]
cdktf debug Get debug information about the current project and environment
cdktf provider A set of subcommands that facilitates provider management
cdktf completion generate completion script
Options:
--version Show version number [boolean]
--disable-plugin-cache-env Dont set TF_PLUGIN_CACHE_DIR automatically. This is useful when the plugin cache is configured differently. Supported using the env CDKTF_DISABLE_PLUGIN_CACHE_ENV. [boolean] [default: false]
--log-level Which log level should be written. Only supported via setting the env CDKTF_LOG_LEVEL [string]
-h, --help Show help [boolean]
Options can be specified via environment variables with the "CDKTF_" prefix (e.g. "CDKTF_OUTPUT")
so the help menu was showing as expected.
@ConorWright did you mean to post this somewhere else? This ticket is meant for the
cdktf-cli
npm package specifically. With v1.0.2 I'm still seeing the error being tracked in #1446
I get this when running a cdktf synth
. They have their own fork of node-pty
Haven't tried it with 1.0.3 yet.
I'm running into similar issues with v1.0.2 (Which fixed some of the aws sdk errors) and now I'm getting
Error: Cannot find module '../build/Release/pty.node'
I got this working, by using a node image and installing bun/cdktf in it. It's a workaround, yes, but I see no other way (yet) to use ctktf with bun in a docker container.
Run these commands in your container (I used the image node:18.17.1
):
export BUN_VERSION=1.0.4
export TERRAFORM_VERSION=1.5.7
npm install -g bun@${BUN_VERSION}
wget -q "https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/terraform_${TERRAFORM_VERSION}_linux_amd64.zip"
unzip "terraform_${TERRAFORM_VERSION}_linux_amd64.zip"
mv terraform /usr/bin/terraform
To test if cdktf is working in the container, execute something like this:
mkdir cdktf-test
cd cdktf-test
bun add cdktf-cli
bun run cdktf init
node_module_register
is being tracked in https://github.com/oven-sh/bun/issues/4290
What version of Bun is running?
1.0.2
What platform is your computer?
Darwin 22.6.0 arm64 arm
What steps can reproduce the bug?
From the host OS
docker run -it --rm --entrypoint bash oven/bun:1.0.2
From within the container
export PATH=$PATH:/root/.bun/bin export BUN_INSTALL=/root/.bun bun i -g cdktf-cli bunx cdktf
What is the expected behavior?
It prints the CLI options
What do you see instead?
then a bunch of minified JS then
Additional information
I've seen different errors depending on the host OS I'm using. Sometimes it's this error, sometimes I see
if I forgot to set the PATH or BUN_INSTALL variables.
There was once occasion where I saw the CLI options, but they all started with
bunx
rather thancdktf
as the CLI in the help menu, likely something having to do w/ the implementation using argv[0]. After that I tried to runand got yet another error of some core node module missing.
Overall I'm attempting to start this as a master ticket coordinating everything else needed in order to get cdktf working in bun.