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

[Known Issue] terraform show output when using tgenv #762

Open
rhoboat opened this issue Jan 15, 2021 · 5 comments
Open

[Known Issue] terraform show output when using tgenv #762

rhoboat opened this issue Jan 15, 2021 · 5 comments
Labels

Comments

@rhoboat
Copy link
Contributor

rhoboat commented Jan 15, 2021

If you're using tgenv to manage your terragrunt versions, you may run into an issue when running terraform.Show using this terraform module in terratest: "github.com/gruntwork-io/terratest/modules/terraform". If you call terraform.Show passing in -json as an option, tgenv will output an info log message to stdout which will get captured as the first line of the output of terraform.Show. When you try to parse that output, you'll end up with a parse error. E.g., this was the errant line I saw:

"\x1b[0;32m[INFO] Getting version from tgenv-version-name\x1b[0;39m\n\x1b[0"

The best fix for this is for tgenv to send this log to stderr, but this issue has been raised already on that repo, and a fix is not yet merged up.

In the meantime, be advised of this issue!

A stopgap solution is to stop using tgenv and install terragrunt using the gruntwork-installer directly, with gruntwork-install --binary-name "terragrunt" --repo "https://github.com/gruntwork-io/terragrunt" --tag "<VERSION>".

@infraredgirl
Copy link
Contributor

If I understand correctly, this is a bug in tgenv? From what I can tell, tgenv does not seem to be actively developed any longer. So the workaround for this issue would be to use the gruntwork-installer as you suggested, or alternatively tgswitch.

If this is indeed a bug in tgenv, and not in terratest, I think we can close this issue - let me know if you agree with that Rho!

@rhoboat
Copy link
Contributor Author

rhoboat commented Jan 20, 2021

I think that makes sense to close the issue! FYI, I added this issue just so that people know that it's still not fixed (open issue vs closed) and that they will see this error. I also noticed that it's a tricky one, and most people who hit this issue will not understand that it's not a terratest bug. So they will probably come here first.

Also, we are planning to make headway on a decision about tgenv/tgswitch, it could work to keep this open until then. I see this as a "open issue, won't fix" (since the fix would need to happen elsewhere). I'm just not sure about open/closed in terms of open-source best practices.

@infraredgirl
Copy link
Contributor

Sure, let's leave it open until then! 👍

@zackproser
Copy link
Contributor

Thanks for this write-up - was helpful as we just ran into the same thing!

@hposca
Copy link

hposca commented May 4, 2021

For posterity, a workaround:

On my ~/.tgenv/libexec/helpers file I had to "update" the info() function to:

function info() {
  # echo -e "\033[0;32m[INFO] ${1}\033[0;39m"
  echo "" &> /dev/null
}

And then it worked :/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants