Managing multiple versions of Terraform can quickly become a hassle — especially when working across different environments or contributing to various projects that rely on specific versions. Fortunately, with tfenv, a Terraform version manager, this task becomes simple and reliable.

If you’re working on Windows and using WSL2 (Windows Subsystem for Linux 2), you can install tfenv inside your WSL Linux distribution exactly as you would on a native Linux system. I was a little wary because looking at the docs on the official GitHub there was only brew setup instructions for Mac. Turns out, everything is OK.

Setting Up tfenv in WSL2

1. Open Your WSL2 Terminal

Start by launching your preferred WSL2 distro. For example, if you’re using Ubuntu, you can open “Ubuntu on Windows” by typing “wsl” on the Start menu or via Windows Terminal.

2. Install Required Dependencies

Make sure the necessary packages are installed. Run the following command to update your package list and install git, unzip, and curl:

sudo apt update && sudo apt install -y git unzip curl

These tools are essential for fetching the tfenv repository and managing Terraform installations.

3. Clone the tfenv Repository

Next, clone the tfenv repository into your home directory under ~/.tfenv:

git clone https://github.com/tfutils/tfenv.git ~/.tfenv

This location is standard and allows easy integration with your environment variables.

4. Add tfenv to Your PATH

To make the tfenv binary available in your shell, append the following line to your shell configuration file. If you’re using Bash, edit ~/.bashrc; for Zsh, use ~/.zshrc:

export PATH="$HOME/.tfenv/bin:$PATH"

After adding the line, reload your shell configuration: source ~/.bashrc

5. Verify the Installation

Confirm that tfenv is correctly installed by checking its version:

tfenv --version

You should see output confirming that tfenv is now available in your shell environment.

Installing and Managing Terraform Versions

With tfenv installed, you can now install and switch between different Terraform versions with ease.

Install the Latest Version

To install the latest stable version of Terraform:

tfenv install latest
tfenv use latest

Install a Specific Version

If your project requires a particular version, you can specify it directly:

tfenv install 1.6.6
tfenv use 1.6.6

tfenv will download and configure the specified version, making it active for your shell session.

Discovering Alpha and Pre-Release Versions

If you’re like me and you’re experimenting with upcoming features like Terraform Stacks, tfenv also lets you access pre-release versions, including betas and alpha builds. You can list available remote versions with:

tfenv list-remote

Here are some of the currently available alpha versions for the upcoming Terraform 1.14.0 release:

1.14.0-alpha20250903
1.14.0-alpha20250827
1.14.0-alpha20250813
1.14.0-alpha20250806
1.14.0-alpha20250724
1.14.0-alpha20250716

These are pre-release builds for Terraform 1.14.0. The version format includes a timestamp indicating the release date of each alpha build. To try one out, you can install it explicitly:

tfenv install 1.14.0-alpha20250903
tfenv use 1.14.0-alpha20250903

Keep in mind that pre-release versions may contain experimental features or bugs, so use them with caution — especially in production environments.

Conclusion

Setting up tfenv in your WSL2 environment gives you the flexibility and control to manage multiple versions of Terraform without cluttering your system. Whether you’re maintaining legacy infrastructure or testing cutting-edge features from the latest alpha builds, tfenv ensures you always have the right version of Terraform at your fingertips.

By following these steps, you’ve now configured a version manager that fits neatly into your Windows world with WSL2. I don’t spend a lot of time on Windows but I’m glad this trick from Mac still works flawlessly even in WSL.

Alt