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

1 Like

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.

3 Likes

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

piggy backing off of your advice, I ran touch ~/.zshrc since I’m using zsh and that fixed the issue for me

1 Like

If anyone is experiencing this on Mac and is using bash instead of zsh then note that you need a ~/.bash_profile file. Having a ~/.bashrc file is not sufficient as this tool only looks for bash_profile file on mac.

1 Like

Hi all, I’m running into this issue and the previous fixes have not worked for me unfortunately.

I’m on Windows 10, running cygwin for a unix-like terminal. It uses bash. I’m in my home directory, and confirmed that .bashrc (and .bash_profile) exist. I’ve tried changing permissions on .bashrc, temporarily deleting it, touching a blank file. Regardless, I always get the same error:

$ terraform -install-autocomplete
Error executing CLI: Did not find any shells to install

I looked at the install.go script - I’m not familiar with the language, but I agree that it seems to just be searching for files named .bashrc, etc.

My best guess was that when terraform runs, it is looking somewhere other than my home for .bashrc and not finding it. But I even tried moving the terraform.exe to my home temporarily, and executing from there, and it still gives the same issue.

I would greatly appreciate any troubleshooting tips if anyone has any :slight_smile: I’m stumped.

Thanks a bunch for your time!
-Stevo