Error executing CLI: Did not find any shells to install

I have a windows 10 machine and have installed gitbash and vagrant on it with a virtual box.

when I run the below command :
$ terraform -install-autocomplete

I am getting this error:
“Error executing CLI: Did not find any shells to install”

i have purposely installed older version of terraform.

$ terraform --version
Terraform v0.12.0

i think my path is correct (please correct if i am wrong

$ echo $PATH
/c/Users/Hardik/bin:/mingw64/bin:/usr/local/bin:/usr/bin:/bin:/mingw64/bin:/usr/bin:/c/Users/Hardik/bin:/c/Windows/system32:/c/Windows:/c/Windows/System32/Wbem:/c/Windows/System32/WindowsPowerShell/v1.0:/c/Windows/System32/OpenSSH:/c/Program Files (x86)/NVIDIA Corporation/PhysX/Common:/c/Program Files/NVIDIA Corporation/NVIDIA NvDLISR:/c/WINDOWS/system32:/c/WINDOWS:/c/WINDOWS/System32/Wbem:/c/WINDOWS/System32/WindowsPowerShell/v1.0:/c/WINDOWS/System32/OpenSSH:/cmd:/c/HashiCorp/Vagrant/bin:/c/Program Files/PuTTY:/c/Users/Hardik/terraform:/c/Users/Hardik/AppData/Local/Microsoft/WindowsApps:/c/Users/Hardik/AppData/Roaming/terraform:/usr/bin/vendor_perl:/usr/bin/core_perl

Hi @hardiku87,

Terraform’s “autocomplete” support is implemented in terms of a third-party library, which is where this error message originates. From looking at the source code of that library I see that its strategy is to search for a number of possible shell configuration files to add its configuration to:

It seems that the error you saw results from this function not finding any of the files it is searching for. Since you said you are using bash I think the series of bash configuration files are the most relevant for you:

  • ~/.bashrc
  • ~/.bash_profile
  • ~/.bash_login
  • ~/.profile

I found a Stack Overflow question about where the bash “rc” file belongs on Git Bash for Windows, which suggests that it expects .bashrc too, so I think that one way to make this work would be to first create the file Terraform autocomplete setup is looking for, using touch:

  • touch ~/.bashrc

You should then have an empty file .bashrc in your home directory. If you then run terraform -install-autocomplete again, it should hopefully find that file and append the Terraform autocomplete setup code to it, and then after you restart the shell it should take effect.

On Unix systems an initial .bashrc (or similar) file is typically created when adding a new user to the system, so I think the autocomplete library is surprised to encounter a situation where you have no configuration file at all.

1 Like

You are God! Thank you so much. I see you have helped so many people also.