<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Abraham Naiborhu</title>
    <description>The latest articles on DEV Community by Abraham Naiborhu (@abrahamparn).</description>
    <link>https://dev.to/abrahamparn</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F2683454%2F646ff8d2-3b9f-4e5f-a7b3-425aecb33cdd.jpeg</url>
      <title>DEV Community: Abraham Naiborhu</title>
      <link>https://dev.to/abrahamparn</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/abrahamparn"/>
    <language>en</language>
    <item>
      <title>Installing Terraform on macOS with Homebrew and Fixing Zsh Autocomplete Error</title>
      <dc:creator>Abraham Naiborhu</dc:creator>
      <pubDate>Sun, 03 May 2026 03:43:44 +0000</pubDate>
      <link>https://dev.to/abrahamparn/installing-terraform-on-macos-with-homebrew-and-fixing-zsh-autocomplete-error-2gn9</link>
      <guid>https://dev.to/abrahamparn/installing-terraform-on-macos-with-homebrew-and-fixing-zsh-autocomplete-error-2gn9</guid>
      <description>&lt;p&gt;After passing Google Professional Cloud Architect, I started learning Terraform to turn cloud architecture knowledge into reproducible Infrastructure as Code.&lt;/p&gt;

&lt;p&gt;This is my first Terraform learning note with a simple goal of &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;install Terraform on macOS&lt;/li&gt;
&lt;li&gt;verify that it works&lt;/li&gt;
&lt;li&gt;enable autocomplete&lt;/li&gt;
&lt;li&gt;document one error I encountered during setup&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Requirements
&lt;/h2&gt;

&lt;p&gt;For this setup, I used Homebrew.&lt;br&gt;
If you do not have Homebrew installed yet, you can install it from:&lt;br&gt;
&lt;code&gt;https://brew.sh/&lt;/code&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  What is Homebrew?
&lt;/h2&gt;

&lt;p&gt;Small info, Homebrew is a package manager for macOS and Linux. It helps install, update, and manage developer tools directly from the terminal.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Reference: This note is based on HashiCorp’s official Terraform installation guide. I rewrote the steps in my own words as part of my personal Terraform learning documentation.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h2&gt;
  
  
  Install Terraform on macOS
&lt;/h2&gt;

&lt;p&gt;First, add HashiCorp’s official Homebrew tap.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;brew tap hashicorp/tap
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Verify the Installation
&lt;/h3&gt;

&lt;p&gt;After installation, check whether Terraform is available.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;terraform &lt;span class="nt"&gt;--version&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can also list Terraform’s available commands.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;terraform &lt;span class="nt"&gt;--help&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To inspect a specific command, add &lt;code&gt;-help&lt;/code&gt;. For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;terraform plan &lt;span class="nt"&gt;-help&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Enable Terraform Autocomplete
&lt;/h2&gt;

&lt;p&gt;Because I am using Zsh on macOS, I first made sure that the Zsh configuration file exists.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;touch&lt;/span&gt; ~/.zshrc
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Or if you are not too sure, go check it with&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;ls&lt;/span&gt; &lt;span class="nt"&gt;-la&lt;/span&gt; .zshrc
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It will output the path to that file.&lt;/p&gt;

&lt;p&gt;Then I installed Terraform autocomplete.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;terraform &lt;span class="nt"&gt;-install-autocomplete&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After installing autocomplete, restart the shell or reload the Zsh configuration.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;source&lt;/span&gt; ~/.zshrc
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  The Error
&lt;/h2&gt;

&lt;p&gt;After running terraform -install-autocomplete, I encountered this error when opening a new terminal window:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;complete&lt;/span&gt;:13: &lt;span class="nb"&gt;command &lt;/span&gt;not found: compdef
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Why This Happened
&lt;/h3&gt;

&lt;p&gt;Terraform autocomplete uses shell completion.&lt;/p&gt;

&lt;p&gt;In my case, Zsh’s completion system was not properly initialized before Terraform’s autocomplete command was loaded.&lt;/p&gt;

&lt;p&gt;Because of that, the terminal could not recognize &lt;code&gt;compdef&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  The Fix
&lt;/h3&gt;

&lt;p&gt;Open the Zsh configuration file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;nano ~/.zshrc
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then make sure the Zsh completion system is initialized before the Terraform autocomplete line.&lt;/p&gt;

&lt;p&gt;My configuration looked like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Initialize Zsh completion system&lt;/span&gt;
autoload &lt;span class="nt"&gt;-Uz&lt;/span&gt; compinit &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; compinit

&lt;span class="c"&gt;# Initialize Bash completion compatibility&lt;/span&gt;
autoload &lt;span class="nt"&gt;-U&lt;/span&gt; +X bashcompinit &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; bashcompinit

&lt;span class="c"&gt;# Terraform CLI autocomplete&lt;/span&gt;
&lt;span class="nb"&gt;complete&lt;/span&gt; &lt;span class="nt"&gt;-o&lt;/span&gt; nospace &lt;span class="nt"&gt;-C&lt;/span&gt; /opt/homebrew/bin/terraform terraform
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Important note: the Terraform path may be different depending on your Mac.&lt;/p&gt;

&lt;p&gt;To check your Terraform path, run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;which terraform
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For Apple Silicon Macs, it is commonly:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;/opt/homebrew/bin/terraform
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Use the path returned by &lt;code&gt;which terraform&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Restart the Shell
&lt;/h2&gt;

&lt;p&gt;After updating &lt;code&gt;.zshrc&lt;/code&gt;, reload it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;source&lt;/span&gt; ~/.zshrc
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Test Autocomplete
&lt;/h2&gt;

&lt;p&gt;Type this without pressing Enter:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;terraform provi
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then press &lt;code&gt;tab&lt;/code&gt;. The result should usually be&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;terraform providers
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  What I Learned
&lt;/h2&gt;

&lt;p&gt;This was a small setup issue, but it reminded me of an important Infrastructure as Code principle:&lt;/p&gt;

&lt;p&gt;Tooling setup matters.&lt;/p&gt;

&lt;p&gt;This is only the first step. Next, I will start learning Terraform providers, resources, variables, outputs, and how Terraform works with Google Cloud.&lt;/p&gt;

</description>
      <category>terraform</category>
      <category>beginners</category>
    </item>
  </channel>
</rss>
