This reference explains how to replace tfenv with the Atmos toolchain. For the skill's decision guide, see ../SKILL.md. For the full toolchain feature reference, see atmos-toolchain. Some users also manage OpenTofu versions with tofuenv, or Terragrunt and TFLint versions with tenv. For these tools, see from-tofuenv.md and from-tenv.md. The steps are the same. Only the tool changes.
tfenv has one purpose. It pins a Terraform version. It uses a .terraform-version file, which
holds a single version string. It also uses the tfenv use X.Y.Z command. The Atmos equivalent is
one line in .tool-versions. For most cases, this migration is mechanical. One gap remains:
tfenv's partial or range-based version selectors. See Functional Gaps.
Before:
# .terraform-version
1.9.8
You can also set the version with the tfenv use 1.9.8 command. This command records the version
in ~/.tfenv/version as the global default. Or it records the version in .terraform-version for
a per-project pin.
After:
# .tool-versions
terraform 1.9.8
# atmos.yaml
toolchain:
aliases:
terraform: hashicorp/terraform
registries:
- name: aqua
type: aqua
source: https://github.com/aquaproj/aqua-registry/tree/main/pkgs
priority: 10atmos toolchain install- Read the current pin. Run
cat .terraform-versionif the file exists. Otherwise, runtfenv version-namefor the current active version. - Add it to
.tool-versions. Appendterraform <version>. Create the file if it does not exist. - Add the
toolchain:block toatmos.yamlif the repository does not already have one. See Before/After above. - Verify the setup. Run
atmos toolchain install. Then runatmos toolchain which terraform. Confirm thatatmos terraform plan <component> -s <stack>uses the expected version. - Promote to
dependencies.toolson the specific component. Do this if the version must apply only to that component, not to the whole repository. See the "Default Rule" in atmos-toolchain. - Remove
.terraform-versionand uninstall tfenv last. Do this only after the team verifies thatatmos terraformcommands resolve the correct version without it.
| tfenv command | Atmos toolchain equivalent |
|---|---|
tfenv install 1.9.8 |
atmos toolchain install terraform@1.9.8 |
tfenv use 1.9.8 |
atmos toolchain set terraform 1.9.8 |
tfenv version-name |
atmos toolchain get terraform |
tfenv list (installed versions) |
atmos toolchain list |
tfenv list-remote (available versions) |
atmos toolchain search terraform |
tfenv uninstall 1.9.8 |
atmos toolchain uninstall terraform@1.9.8 |
tfenv works through shimming. Its installer adds ~/.tfenv/bin to PATH. It typically does this
with export PATH="$HOME/.tfenv/bin:$PATH" in ~/.bashrc or ~/.zshrc. The terraform shim
re-reads the nearest .terraform-version file on every command. As a result, plain terraform
always resolves to the correct version in any shell. This setup needs no per-project configuration.
The Atmos toolchain does not do this by default. Atmos resolves tools declared in
dependencies.tools and injects them into PATH. It does this only for the duration of one
atmos <subcommand> command. If you run plain terraform in your shell, it will not use the
Atmos-managed version. To use it, you must opt in to shell integration. This is a supported
mode, not a limitation. Use atmos toolchain env to export the resolved PATH into your
interactive shell:
Bash (add to ~/.bashrc):
eval "$(atmos toolchain env --format=bash)"Zsh (add to ~/.zshrc):
eval "$(atmos toolchain env --format=bash)"Atmos has no separate --format=zsh option. The bash format emits plain POSIX
export PATH=... syntax. Zsh evaluates this syntax the same way.
Fish (add to ~/.config/fish/config.fish):
atmos toolchain env --format=fish | sourcePowerShell (add to $PROFILE):
Invoke-Expression (atmos toolchain env --format powershell | Out-String)Verify the result with which terraform. On PowerShell, use Get-Command terraform. The command
must resolve to the Atmos toolchain install directory, not the tfenv shim.
Important: this is a static snapshot, not tfenv's dynamic per-directory resolution. tfenv's
shim re-reads .terraform-version on every command. So when you cd into a different project,
tfenv switches versions automatically. atmos toolchain env sets PATH once, at eval time, using
the resolved paths of the current directory. It does not update automatically when you cd.
Re-run the eval line after you switch projects. Or use atmos terraform ... instead of bare
terraform when you work across multiple projects. The atmos terraform ... command always
resolves the version per invocation, regardless of shell state.
- The Atmos toolchain has no equivalent for partial or range-based version selectors yet.
tfenv supports selectors like
latest:^1.5orlatest:1.9.*throughtfenv installarguments. These selectors use a partial constraint and select the latest matching release. Atmos toolchain version specs support exact versions,latest,pr:<n>,sha:<hex>, andref:<branch/tag>. SemVer range constraints, such as~> 1.9.0or>= 1.8.0, < 2.0.0, are documented as planned, not yet implemented. If the user relies on a floating constraint, pin an exact version for now. Note that range support is coming.
- atmos-toolchain SKILL.md: covers
.tool-versions,dependencies.tools, and version spec syntax. - atmos-toolchain commands-reference.md: full CLI command reference.
- from-tofuenv.md: same steps, for OpenTofu.
- from-tenv.md: same steps, for tenv's multi-tool version files.