{"id":13484863,"url":"https://github.com/tfutils/tfenv","last_synced_at":"2025-05-13T19:16:26.162Z","repository":{"id":37412796,"uuid":"64857500","full_name":"tfutils/tfenv","owner":"tfutils","description":"Terraform version manager","archived":false,"fork":false,"pushed_at":"2024-07-11T10:05:46.000Z","size":412,"stargazers_count":4677,"open_issues_count":85,"forks_count":463,"subscribers_count":45,"default_branch":"master","last_synced_at":"2025-05-12T05:47:09.841Z","etag":null,"topics":["bash","terraform"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tfutils.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-08-03T15:33:29.000Z","updated_at":"2025-05-10T07:04:18.000Z","dependencies_parsed_at":"2023-02-10T01:00:23.395Z","dependency_job_id":"1d1528a8-b54a-4afd-a85b-6355d1ba8711","html_url":"https://github.com/tfutils/tfenv","commit_stats":{"total_commits":341,"total_committers":91,"mean_commits":"3.7472527472527473","dds":0.7302052785923754,"last_synced_commit":"39d8c27ad9862ffdec57989b66fd2720cb72e76c"},"previous_names":[],"tags_count":27,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tfutils%2Ftfenv","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tfutils%2Ftfenv/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tfutils%2Ftfenv/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tfutils%2Ftfenv/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tfutils","download_url":"https://codeload.github.com/tfutils/tfenv/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253685179,"owners_count":21947303,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bash","terraform"],"created_at":"2024-07-31T17:01:36.869Z","updated_at":"2025-05-13T19:16:26.123Z","avatar_url":"https://github.com/tfutils.png","language":"Shell","readme":"[![CI Test](https://github.com/tfutils/tfenv/actions/workflows/test.yml/badge.svg)](https://github.com/tfutils/tfenv/actions/workflows/test.yml)\n\n# tfenv\n\n[Terraform](https://www.terraform.io/) version manager inspired by [rbenv](https://github.com/rbenv/rbenv)\n\n## Support\n\nCurrently tfenv supports the following OSes\n\n- macOS\n  - 64bit\n  - Arm (Apple Silicon)\n- Linux\n  - 64bit\n  - Arm\n- Windows (64bit) - only tested in git-bash - currently presumed failing due to symlink issues in git-bash\n\n## Installation\n\n### Automatic\n\nInstall via Homebrew\n\n```console\nbrew install tfenv\n```\n\nInstall via Arch User Repository (AUR)\n   \n```console\nyay --sync tfenv\n```\n\nInstall via puppet\n\nUsing puppet module [sergk-tfenv](https://github.com/SergK/puppet-tfenv)\n\n```puppet\ninclude ::tfenv\n```\n\n### Manual\n\n1. Check out tfenv into any path (here is `${HOME}/.tfenv`)\n\n```console\ngit clone --depth=1 https://github.com/tfutils/tfenv.git ~/.tfenv\n```\n\n2. Add `~/.tfenv/bin` to your `$PATH` any way you like\n\nbash:\n```console\necho 'export PATH=\"$HOME/.tfenv/bin:$PATH\"' \u003e\u003e ~/.bash_profile\n```\nzsh:\n```console\n$ echo 'export PATH=\"$HOME/.tfenv/bin:$PATH\"' \u003e\u003e ~/.zprofile\n```\n\nFor WSL users:\n```bash\necho 'export PATH=$PATH:$HOME/.tfenv/bin' \u003e\u003e ~/.bashrc\n```\n\n  OR you can make symlinks for `tfenv/bin/*` scripts into a path that is already added to your `$PATH` (e.g. `/usr/local/bin`) `OSX/Linux Only!`\n\n```console\nln -s ~/.tfenv/bin/* /usr/local/bin\n```\n\n  On Ubuntu/Debian touching `/usr/local/bin` might require sudo access, but you can create `${HOME}/bin` or `${HOME}/.local/bin` and on next login it will get added to the session `$PATH`\n  or by running `. ${HOME}/.profile` it will get added to the current shell session's `$PATH`.\n\n```console\nmkdir -p ~/.local/bin/\n. ~/.profile\nln -s ~/.tfenv/bin/* ~/.local/bin\nwhich tfenv\n```\n\n## Usage\n\n### tfenv install [version]\n\nInstall a specific version of Terraform.\n\nIf no parameter is passed, the version to use is resolved automatically via [TFENV\\_TERRAFORM\\_VERSION environment variable](#tfenv_terraform_version) or [.terraform-version files](#terraform-version-file), in that order of precedence, i.e. TFENV\\_TERRAFORM\\_VERSION, then .terraform-version. The default is 'latest' if none are found.\n\nIf a parameter is passed, available options:\n\n- `x.y.z` [Semver 2.0.0](https://semver.org/) string specifying the exact version to install\n- `latest` is a syntax to install latest version\n- `latest:\u003cregex\u003e` is a syntax to install latest version matching regex (used by grep -e)\n- `latest-allowed` is a syntax to scan your Terraform files to detect which version is maximally allowed.\n- `min-required` is a syntax to scan your Terraform files to detect which version is minimally required.\n\nSee [required_version](https://developer.hashicorp.com/terraform/language/settings) docs. Also [see min-required \u0026 latest-allowed](#min-required) section below.\n\n```console\n$ tfenv install\n$ tfenv install 0.7.0\n$ tfenv install latest\n$ tfenv install latest:^0.8\n$ tfenv install latest-allowed\n$ tfenv install min-required\n```\n\nIf `shasum` is present in the path, tfenv will verify the download against Hashicorp's published sha256 hash.\nIf [keybase](https://keybase.io/) is available in the path it will also verify the signature for those published hashes using Hashicorp's published public key.\n\nYou can opt-in to using GnuPG tools for PGP signature verification if keybase is not available:\n\nWhere `TFENV_INSTALL_DIR` is for example, `~/.tfenv` or `/usr/local/Cellar/tfenv/\u003cversion\u003e`\n\n```console\necho 'trust-tfenv: yes' \u003e ${TFENV_INSTALL_DIR}/use-gpgv\ntfenv install\n```\n\nThe `trust-tfenv` directive means that verification uses a copy of the\nHashicorp OpenPGP key found in the tfenv repository.  Skipping that directive\nmeans that the Hashicorp key must be in the existing default trusted keys.\nUse the file `${TFENV_INSTALL_DIR}/use-gnupg` to instead invoke the full `gpg` tool and\nsee web-of-trust status; beware that a lack of trust path will not cause a\nvalidation failure.\n\n#### .terraform-version\n\nIf you use a [.terraform-version](#terraform-version-file) file, `tfenv install` (no argument) will install the version written in it.\n\n\u003ca name=\"min-required\"\u003e\u003c/a\u003e\n#### min-required \u0026 latest-allowed\n\nPlease note that we don't do semantic version range parsing but use first ever found version as the candidate for minimally required one. It is up to the user to keep the definition reasonable. I.e.\n\n```terraform\n// this will detect 0.12.3\nterraform {\n  required_version  = \"\u003c0.12.3, \u003e= 0.10.0\"\n}\n```\n\n```terraform\n// this will detect 0.10.8 (the latest 0.10.x release)\nterraform {\n  required_version  = \"~\u003e 0.10.0, \u003c0.12.3\"\n}\n```\n\n### Environment Variables\n\n#### TFENV\n\n##### `TFENV_ARCH`\n\nString (Default: `amd64`)\n\nSpecify architecture. Architecture other than the default amd64 can be specified with the `TFENV_ARCH` environment variable\n\nNote: Default changes to `arm64` for versions that have arm64 builds available when `$(uname -m)` matches `aarch64* | arm64*`\n\n```console\nTFENV_ARCH=arm64 tfenv install 0.7.9\n```\n\n##### `TFENV_AUTO_INSTALL`\n\nString (Default: true)\n\nShould tfenv automatically install terraform if the version specified by defaults or a .terraform-version file is not currently installed.\n\n```console\nTFENV_AUTO_INSTALL=false terraform plan\n```\n\n```console\nterraform use \u003cversion that is not yet installed\u003e\n```\n\n##### `TFENV_CURL_OUTPUT`\n\nInteger (Default: 2)\n\nSet the mechanism used for displaying download progress when downloading terraform versions from the remote server.\n\n* 2: v1 Behaviour: Pass `-#` to curl\n* 1: Use curl default\n* 0: Pass `-s` to curl\n\n##### `TFENV_DEBUG`\n\nInteger (Default: 0)\n\nSet the debug level for TFENV.\n\n* 0: No debug output\n* 1: Simple debug output\n* 2: Extended debug output, with source file names and interactive debug shells on error\n* 3: Debug level 2 + Bash execution tracing\n\n##### `TFENV_REMOTE`\n\nString (Default: https://releases.hashicorp.com)\n\nTo install from a remote other than the default\n\n```console\nTFENV_REMOTE=https://example.jfrog.io/artifactory/hashicorp\n```\n\n##### `TFENV_REVERSE_REMOTE`\n\nInteger (Default: 0)\n\nWhen using a custom remote, such as Artifactory, instead of the Hashicorp servers,\nthe list of terraform versions returned by the curl of the remote directory may be inverted.\nIn this case the `latest` functionality will not work as expected because it expects the\nversions to be listed in order of release date from newest to oldest. If your remote\nis instead providing a list that is oldes-first, set `TFENV_REVERSE_REMOTE=1` and\nfunctionality will be restored.\n\n```console\nTFENV_REVERSE_REMOTE=1 tfenv list-remote\n```\n\n##### `TFENV_CONFIG_DIR`\n\nPath (Default: `$TFENV_ROOT`)\n\nThe path to a directory where the local terraform versions and configuration files exist.\n\n```console\nTFENV_CONFIG_DIR=\"$XDG_CONFIG_HOME/tfenv\"\n```\n\n##### `TFENV_TERRAFORM_VERSION`\n\nString (Default: \"\")\n\nIf not empty string, this variable overrides Terraform version, specified in [.terraform-version files](#terraform-version-file).\n`latest` and `latest:\u003cregex\u003e` syntax are also supported.\n[`tfenv install`](#tfenv-install-version) and [`tfenv use`](#tfenv-use-version) command also respects this variable.\n\ne.g.\n\n```console\nTFENV_TERRAFORM_VERSION=latest:^0.11. terraform --version\n```\n\n##### `TFENV_NETRC_PATH`\n\nString (Default: \"\")\n\nIf not empty string, this variable specifies the credentials file used to access the remote location (useful if used in conjunction with TFENV_REMOTE).\n\ne.g.\n\n```console\nTFENV_NETRC_PATH=\"$PWD/.netrc.tfenv\"\n```\n\n#### Bashlog Logging Library\n\n##### `BASHLOG_COLOURS`\n\nInteger (Default: 1)\n\nTo disable colouring of console output, set to 0.\n\n\n##### `BASHLOG_DATE_FORMAT`\n\nString (Default: +%F %T)\n\nThe display format for the date as passed to the `date` binary to generate a datestamp used as a prefix to:\n\n* `FILE` type log file lines.\n* Each console output line when `BASHLOG_EXTRA=1`\n\n##### `BASHLOG_EXTRA`\n\nInteger (Default: 0)\n\nBy default, console output from tfenv does not print a date stamp or log severity.\n\nTo enable this functionality, making normal output equivalent to FILE log output, set to 1.\n\n##### `BASHLOG_FILE`\n\nInteger (Default: 0)\n\nSet to 1 to enable plain text logging to file (FILE type logging).\n\nThe default path for log files is defined by /tmp/$(basename $0).log\nEach executable logs to its own file.\n\ne.g.\n\n```console\nBASHLOG_FILE=1 tfenv use latest\n```\n\nwill log to `/tmp/tfenv-use.log`\n\n##### `BASHLOG_FILE_PATH`\n\nString (Default: /tmp/$(basename ${0}).log)\n\nTo specify a single file as the target for all FILE type logging regardless of the executing script.\n\n##### `BASHLOG_I_PROMISE_TO_BE_CAREFUL_CUSTOM_EVAL_PREFIX`\n\nString (Default: \"\")\n\n*BE CAREFUL - MISUSE WILL DESTROY EVERYTHING YOU EVER LOVED*\n\nThis variable allows you to pass a string containing a command that will be executed using `eval` in order to produce a prefix to each console output line, and each FILE type log entry.\n\ne.g.\n\n```console\nBASHLOG_I_PROMISE_TO_BE_CAREFUL_CUSTOM_EVAL_PREFIX='echo \"${$$} \"'\n```\nwill prefix every log line with the calling process' PID.\n\n##### `BASHLOG_JSON`\n\nInteger (Default: 0)\n\nSet to 1 to enable JSON logging to file (JSON type logging).\n\nThe default path for log files is defined by /tmp/$(basename $0).log.json\nEach executable logs to its own file.\n\ne.g.\n\n```console\nBASHLOG_JSON=1 tfenv use latest\n```\n\nwill log in JSON format to `/tmp/tfenv-use.log.json`\n\nJSON log content:\n\n`{\"timestamp\":\"\u003cdate +%s\u003e\",\"level\":\"\u003clog-level\u003e\",\"message\":\"\u003clog-content\u003e\"}`\n\n##### `BASHLOG_JSON_PATH`\n\nString (Default: /tmp/$(basename ${0}).log.json)\n\nTo specify a single file as the target for all JSON type logging regardless of the executing script.\n\n##### `BASHLOG_SYSLOG`\n\nInteger (Default: 0)\n\nTo log to syslog using the `logger` binary, set this to 1.\n\nThe basic functionality is thus:\n\n```console\nlocal tag=\"${BASHLOG_SYSLOG_TAG:-$(basename \"${0}\")}\";\nlocal facility=\"${BASHLOG_SYSLOG_FACILITY:-local0}\";\nlocal pid=\"${$}\";\nlogger --id=\"${pid}\" -t \"${tag}\" -p \"${facility}.${severity}\" \"${syslog_line}\"\n```\n\n##### `BASHLOG_SYSLOG_FACILITY`\n\nString (Default: local0)\n\nThe syslog facility to specify when using SYSLOG type logging.\n\n##### `BASHLOG_SYSLOG_TAG`\n\nString (Default: $(basename $0))\n\nThe syslog tag to specify when using SYSLOG type logging.\n\nDefaults to the PID of the calling process.\n\n\n\n### tfenv use [version]\n\nSwitch a version to use\n\nIf no parameter is passed, the version to use is resolved automatically via [.terraform-version files](#terraform-version-file) or [TFENV\\_TERRAFORM\\_VERSION environment variable](#tfenv_terraform_version) (TFENV\\_TERRAFORM\\_VERSION takes precedence), defaulting to 'latest' if none are found.\n\n`latest` is a syntax to use the latest installed version\n\n`latest:\u003cregex\u003e` is a syntax to use latest installed version matching regex (used by grep -e)\n\n`min-required` will switch to the version minimally required by your terraform sources (see above `tfenv install`)\n\n```console\n$ tfenv use\n$ tfenv use min-required\n$ tfenv use 0.7.0\n$ tfenv use latest\n$ tfenv use latest:^0.8\n```\n\nNote: `tfenv use latest` or `tfenv use latest:\u003cregex\u003e` will find the latest matching version that is already installed. If no matching versions are installed, and TFENV_AUTO_INSTALL is set to `true` (which is the default) the the latest matching version in the remote repository will be installed and used.\n\n### tfenv uninstall \u0026lt;version\u003e\n\nUninstall a specific version of Terraform\n`latest` is a syntax to uninstall latest version\n`latest:\u003cregex\u003e` is a syntax to uninstall latest version matching regex (used by grep -e)\n\n```console\n$ tfenv uninstall 0.7.0\n$ tfenv uninstall latest\n$ tfenv uninstall latest:^0.8\n```\n\n### tfenv list\n\nList installed versions\n\n```console\n$ tfenv list\n* 0.10.7 (set by /opt/tfenv/version)\n  0.9.0-beta2\n  0.8.8\n  0.8.4\n  0.7.0\n  0.7.0-rc4\n  0.6.16\n  0.6.2\n  0.6.1\n```\n\n### tfenv list-remote\n\nList installable versions\n\n```console\n$ tfenv list-remote\n0.9.0-beta2\n0.9.0-beta1\n0.8.8\n0.8.7\n0.8.6\n0.8.5\n0.8.4\n0.8.3\n0.8.2\n0.8.1\n0.8.0\n0.8.0-rc3\n0.8.0-rc2\n0.8.0-rc1\n0.8.0-beta2\n0.8.0-beta1\n0.7.13\n0.7.12\n...\n```\n\n## .terraform-version file\n\nIf you put a `.terraform-version` file on your project root, or in your home directory, tfenv detects it and uses the version written in it. If the version is `latest` or `latest:\u003cregex\u003e`, the latest matching version currently installed will be selected.\n\nNote, that [TFENV\\_TERRAFORM\\_VERSION environment variable](#tfenv_terraform_version) can be used to override version, specified by `.terraform-version` file.\n\n```console\n$ cat .terraform-version\n0.6.16\n\n$ terraform version\nTerraform v0.6.16\n\nYour version of Terraform is out of date! The latest version\nis 0.7.3. You can update by downloading from www.terraform.io\n\n$ echo 0.7.3 \u003e .terraform-version\n\n$ terraform version\nTerraform v0.7.3\n\n$ echo latest:^0.8 \u003e .terraform-version\n\n$ terraform version\nTerraform v0.8.8\n\n$ TFENV_TERRAFORM_VERSION=0.7.3 terraform --version\nTerraform v0.7.3\n```\n\n## Upgrading\n\n```console\ngit --git-dir=~/.tfenv/.git pull\n```\n\n## Uninstalling\n\n```console\nrm -rf /some/path/to/tfenv\n```\n\n## LICENSE\n\n- [tfenv itself](https://github.com/tfutils/tfenv/blob/master/LICENSE)\n- [rbenv](https://github.com/rbenv/rbenv/blob/master/LICENSE)\n  - tfenv partially uses rbenv's source code\n","funding_links":[],"categories":["Productivity Tools","Shell","Tools","Infrastructure as Code","Version Managers","Dependency management","bash","List of \\*env-, ch\\*- and \\*vm- style version managers"],"sub_categories":["Miscellaneous","Terraform Tooling","Terraform","Community providers","Shell into containers"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftfutils%2Ftfenv","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftfutils%2Ftfenv","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftfutils%2Ftfenv/lists"}