infracost / vscode-infracost

See cost estimates for Terraform right in your editor💰📉

Home Page:https://www.infracost.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Extension cannot find the infracost binary

danielbmeireles opened this issue · comments

Dear Infracost community, how are you?

The following error is displayed when I open any TY project:

The Infracost extension requires the Infracost CLI to function. Please install it: https://www.infracost.io/docs/#1-install-infracost.

But:

$ infracost --version
Infracost v0.10.12

$ which infracost
/opt/homebrew/bin/infracost

The brew prefix is different because I am running Infracost in an M1 Pro system, as stated here: https://docs.brew.sh/FAQ#why-is-the-default-installation-prefix-opthomebrew-on-apple-silicon

OS: macOS 12.6 21G115 arm64
Host: MacBookPro18,1
Kernel: 21.6.0
Shell: zsh 5.8.1
CPU: Apple M1 Pro
GPU: Apple M1 Pro

Is there any way I can set the infracost path used by the extension?

@danielbmeireles Hello 👋! Thank you for creating the issue!

Currently, it is impossible to specify the path to the binary, but I think it could be a great setting. I'll bring this to the team as a future improvement. Thank you for the suggestion :)

However, this is strange. I'm using the extension on M1 as well, and it works fine. Checking echo $PATH shows that /opt/homebrew/bin is there. Running which in the console tells me your PATH also looks okay. Now I wonder if vscode doesn't load it properly.

I'm not using vscode, so a quick google search didn't help me to find if there is an option to specify the path. Have you tried to reinstall the CLI? I'm sorry for the advice, but surprisingly it helped me many times :D

Hello!

I tried to reinstall the extension, but the error persists:

The Infracost extension requires the Infracost CLI to function. Please install it: https://www.infracost.io/docs/#1-install-infracost.

image

I also check my $PATH variable and everything looks A-OK:

$ echo $PATH
/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/meireld/.terraform.binary

Is there a way to collect logs from the extension? Maybe I can try to debug what is going on...

Hi @danielbmeireles, thanks for providing details about this. Debug logs can be found by following the guide here: https://github.com/infracost/vscode-infracost#locating-infracost-error-logs

This might be something to do with the fact that VSCode is not picking up the updated PATH when you install the extension. Here are a couple of questions to help us to debug:

  1. Open a Terraform repo & paste the output from any error logs that seem suspicious when the "Infracost extension is required" error appears.
  2. Make sure Infracost CLI is installed and then restart VSCode completely. Does this resolve the issue?
  3. If the above doesn't work. Can you uninstall and install the extension again? Does this resolve the issue?
  4. If neither of the above work, open a VSCode terminal and see if you can access Infracost CLI in that interactive shell. If not what does a echo $PATH give

Thanks

Hello!

I removed the extension and closed VSCode. After that, I re-installed the extension, and everything is A-OK now 🤓

Thank you so much for your patience!

Thanks, @danielbmeireles. This seems like it is most likely a UX on our side with the $PATH not being updated for the current VSCode session, meaning users will need to reload live sessions after installing the binary. However, I'm going to close this issue as this problem should be fixed by an upcoming release of the extension where we bundle the binary. This means users won't have to install the binary separately. Thanks for your help, and I'm glad you got to success 🚀