Skip to content

bug: remove the need for expects' unbuffer command while using coder cli to push a template #17033

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
1 task done
alfred-stokespace opened this issue Mar 21, 2025 · 5 comments · Fixed by #17067
Closed
1 task done
Assignees
Labels
s2 Broken use cases or features (with a workaround). Only humans may set this.

Comments

@alfred-stokespace
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

cli version Coder v2.20.0+03b5012 Tue Mar 4 19:21:19 UTC 2025
(I tried a new cli as well, same issue)

I'm working in a GitHub Actions Workflow environment.
I have an on-prem Coder Server install (Coder v2.20.0+03b5012 Tue Mar 4 19:21:19 UTC 2025)

I'm using coder cli and an access token provided vie GH secrets

I have a directory with a pre-existing and previously pushed template (shown from within GH Action WF)

ls -altr

total 32
drwxr-xr-x 3 alfreds alfreds 4096 Mar 20 09:47 ..
-rw-r--r-- 1 alfreds alfreds 1479 Mar 20 11:46 README.md
-rw-r--r-- 1 alfreds alfreds 7185 Mar 20 13:59 main.tf
drwx------ 2 alfreds alfreds 4096 Mar 20 16:38 .

when I issue coder template push docker --ignore-lockfile -y
I get this error...

2025-03-20 23:55:55.856Z Terraform 1.10.5
2025-03-20 23:55:55.857Z Error: No configuration files
2025-03-20 23:55:55.857Z Plan requires configuration to be present. Planning without a configuration would mark everything for destruction, which is normally not what is desired. If you would like to destroy everything, run plan with the -destroy option. Otherwise, create a Terraform configuration file (.tf file) and try again.
=== ✔ Detecting persistent resources [161ms]
==> ⧗ Cleaning Up
Encountered an error running "coder templates push", see "coder templates push --help" for more information

I double-triple confirmed that the directory this was running in had the main.tf file.

I got suspicious, so I ssh'd into the runner and manually replicated the command, (over ssh) and it succceeded!

So, I got took that knowledge and made a wild guess that there is a requirement that tty-like relationship is expected to the cli.

I changed the gh wf to install expect

      - name: Hack for Coder bug
        run: |
          sudo apt-get install expect -y
          echo "now unbuffer is available which can trick coder into thinking your are there watching."

and that allows me to add unbuffer before the whole command.

      - name: Push with Coder
        run: |          
          coder whoami
          cd coder/coder-templates/ubuntu/docker          
          unbuffer coder template push docker --ignore-lockfile -y

And that works.

[REDACTED]... You're authenticated as gh-runner !
25l

◰ Uploading directory...25h
=== ✔ Queued [0ms]
==> ⧗ Running
==> ⧗ Running
=== ✔ Running [9ms]
==> ⧗ Setting up
=== ✔ Setting up [0ms]
==> ⧗ Parsing template parameters
=== ✔ Parsing template parameters [14ms]
==> ⧗ Detecting persistent resources
2025-03-20 23:36:18.472Z Terraform 1.10.5
2025-03-20 23:36:19.347Z data.coder_workspace_owner.me: Refreshing...
2025-03-20 23:36:19.347Z data.coder_provisioner.me: Refreshing...
2025-03-20 23:36:19.347Z data.coder_workspace.me: Refreshing...
...
=== ✔ Detecting ephemeral resources [2749ms]
==> ⧗ Cleaning Up
=== ✔ Cleaning Up [353ms]
┌──────────────────────────────────┐
│ Template Preview                 │
├──────────────────────────────────┤
│ RESOURCE                         │
├──────────────────────────────────┤
│ docker_container.workspace       │
│ └─ main (linux, amd64)           │
├──────────────────────────────────┤
│ docker_image.stoke-ubuntu        │
├──────────────────────────────────┤
│ docker_volume.home_volume        │
└──────────────────────────────────┘
Updated version at Mar 20 23:36:23!

Relevant Log Output

Expected Behavior

I should not have to use unbuffer or any other tty-like command in a headless environment to engage with templates push

Steps to Reproduce

  1. See my description, pretty clear what the steps are.

Environment

  • Host OS: version in description
  • Coder version: version in description

Additional Context

No response

@alfred-stokespace alfred-stokespace added the needs-triage Issue that require triage label Mar 21, 2025
@matifali matifali added s2 Broken use cases or features (with a workaround). Only humans may set this. and removed needs-triage Issue that require triage labels Mar 21, 2025
@matifali
Copy link
Member

matifali commented Mar 21, 2025

Thanks for reporting. I have also seen this error intermittently. It's a good investigation to try to find the root cause.
An example where it failed with same error in CI: https://github.com/coder/coder/actions/runs/13457789357/job/37605832347

@mtojek
Copy link
Member

mtojek commented Mar 21, 2025

Have you tried to push with --force-tty flag?

@alfred-stokespace
Copy link
Author

@mtojek

 coder templates push -help | grep force

shows no such command like that on push.

same for global help

 coder -help | grep force

I do see in source code there is mention of force-tty

varForceTty = "force-tty"

I guess I can give it a try. Thanks.

@alfred-stokespace
Copy link
Author

@mtojek

 coder templates push -help | grep force

shows no such command like that on push.

same for global help

 coder -help | grep force

I do see in source code there is mention of force-tty

coder/cli/root.go

Line 65 in b791672

varForceTty = "force-tty"
I guess I can give it a try. Thanks.

Yes, that works...


  coder whoami
  cd coder/coder-templates/ubuntu/docker          
  coder template push docker --ignore-lockfile -y --force-tty
  
  ...
  
    Coder [REDACTED], You're authenticated as gh-runner !
=== ✔ Queued [0ms]
==> ⧗ Running
==> ⧗ Running
=== ✔ Running [11ms]
==> ⧗ Setting up
=== ✔ Setting up [0ms]
==> ⧗ Parsing template parameters
=== ✔ Parsing template parameters [17ms]
==> ⧗ Detecting persistent resources
2025-03-21 13:43:05.905Z Terraform 1.10.5
2025-03-21 13:43:06.916Z data.coder_provisioner.me: Refreshing...
2025-03-21 13:43:06.916Z data.coder_workspace_owner.me: Refreshing...
```

@alfred-stokespace
Copy link
Author

So,... as stated I suppose you could say the bug is "fixed" since --force-tty is a solution.
However, the mystery path to finding this (as noted, the --help's don't show this flag on either the leaf command or the root command) suggests this should probably be easier to find or detected automatically so that it "just works", thoughts?

@mtojek mtojek self-assigned this Mar 24, 2025
mtojek added a commit that referenced this issue Mar 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
s2 Broken use cases or features (with a workaround). Only humans may set this.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants