Skip to content
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

Terraform shell completion fails without TENV_DETACHED_PROXY=false #334

Open
willvousden opened this issue Jan 14, 2025 · 7 comments
Open
Assignees
Labels
bug Something isn't working question Further information is requested TENV_DETACHED_PROXY

Comments

@willvousden
Copy link

willvousden commented Jan 14, 2025

Describe the bug
I've installed tenv on macOS via Homebrew, and set up zsh completion like so:

complete -o nospace -C /opt/homebrew/bin/terraform terraform

I'd like the shell to use whichever version of Terraform is currently in use, hence using the proxy binary in /opt/homebrew.

When I type terraform<tab> I get the following output:

% terraform
/opt/homebrew/bin/tenv:  Failure                  call                     during                   not                      supported
:                        by                       device                   fork/exec                operation                terraform

If I run terraform -install-autocomplete, the following is added to my .zshrc, which works fine, but is tied to a specific tenv version (and it will break if I uninstall that version):

complete -o nospace -C /Users/wvousden/.tenv/Terraform/1.10.4/terraform terraform

A workaround here is to dynamically look up the path to the terraform binary using tenv tf detect, but this command doesn't have an option to output the path (or the version) in a machine-readable format, so it means parsing the human-readable output:

% tenv tf detect
Resolved version from /Users/wvousden/.tenv/Terraform/version : 1.10.4
Terraform 1.10.4 will be run from this directory.

To Reproduce
Steps to reproduce the behavior:

  1. Install tenv in Homebrew
  2. Configure zsh completion with the following:
    complete -o nospace -C /opt/homebrew/bin/terraform terraform
  3. Type terraform<tab>

Expected behavior
I expect to see Terraform's subcommands listed.

Environment:

  • OS: macOS 15.2
  • tenv version: 4.1.0

Additional context
Add any other context about the problem here.

@kvendingoldo kvendingoldo added bug Something isn't working question Further information is requested labels Jan 14, 2025
@willvousden
Copy link
Author

willvousden commented Jan 14, 2025

Looks like this is related to this: #305

If I add export TENV_DETACHED_PROXY=false in my .zshrc before complete, it works. But I'm not sure what consequences this will have. Presumably there's a good reason the default is true?

FWIW, the official Terraform extension for VS Code is also broken unless either VS Code is launched with TENV_DETACHED_PROXY=true (which is awkward to do) or the extension is configured to use a terraform binary from ~/.tenv directly.

@willvousden willvousden changed the title Terraform shell completion fails Terraform shell completion fails without TENV_DETACHED_PROXY=false Jan 14, 2025
@kvendingoldo
Copy link
Collaborator

Thank you for the catch! We'll think about resolving such issue!

@creeder-uturn
Copy link

Looks like this is related to this: #305

If I add export TENV_DETACHED_PROXY=false in my .zshrc before complete, it works. But I'm not sure what consequences this will have. Presumably there's a good reason the default is true?

FWIW, the official Terraform extension for VS Code is also broken unless either VS Code is launched with TENV_DETACHED_PROXY=true (which is awkward to do) or the extension is configured to use a terraform binary from ~/.tenv directly.

I can clarify the consequences of setting it to False - if you Cntrl+C a running apply, it will forcefully close instead of attempting a graceful close. This can result in losing the state of anything actively being applied. Provided you are careful not to Cntrl+C any running plans, it's my belief you can safely set it to false in your profile.

@archoversight
Copy link

This also causes failures when running this from Neovim for example, using r!terraform version or running it through terraform-ls for format actions.

Question, why is tenv after resolving which terraform binary to use not just calling exec and replacing itself with the binary to be loaded? Then that running binary would be able to receive Ctrl + C without issues?

execvp and friends in C.

@dvaumoron
Copy link
Contributor

Can you test v4.2.0-beta2 ?

@dvaumoron dvaumoron self-assigned this Feb 5, 2025
@verygitmuchhub
Copy link

v4.2.0-beta2 does fix completion and terraform-ls autoformatting with nvim for me. Any news on when a "usable" stable version might "fix" the accidental AUR upload (so I do not have to "maintain" my own PKGBUILD)? :)

@kvendingoldo
Copy link
Collaborator

kvendingoldo commented Feb 6, 2025

@dvaumoron I think that we're ready to release v4.2.0. Let's do that?
@verygitmuchhub the release will fix the official AUR repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working question Further information is requested TENV_DETACHED_PROXY
Projects
None yet
Development

No branches or pull requests

6 participants