1--- 2title: "Installation" 3description: "terraform-docs installation guide" 4menu: 5 docs: 6 parent: "user-guide" 7weight: 110 8toc: true 9--- 10 11`terraform-docs` is available on Linux, macOS, Windows, and FreeBSD platforms. 12 13## Homebrew 14 15If you are a macOS user, you can use [Homebrew]. 16 17```bash 18brew install terraform-docs 19``` 20 21or 22 23```bash 24brew install terraform-docs/tap/terraform-docs 25``` 26 27## Windows 28 29If you are a Windows user: 30 31### Scoop 32 33You can use [Scoop]. 34 35```bash 36scoop bucket add terraform-docs https://github.com/terraform-docs/scoop-bucket 37scoop install terraform-docs 38``` 39 40### Chocolatey 41 42or you can use [Chocolatey]. 43 44```bash 45choco install terraform-docs 46``` 47 48## Docker 49 50terraform-docs can be run as a container by mounting a directory with `.tf` 51files in it and run the following command: 52 53```bash 54docker run --rm --volume "$(pwd):/terraform-docs" -u $(id -u) quay.io/terraform-docs/terraform-docs:0.16.0 markdown /terraform-docs 55``` 56 57If `output.file` is not enabled for this module, generated output can be redirected 58back to a file: 59 60```bash 61docker run --rm --volume "$(pwd):/terraform-docs" -u $(id -u) quay.io/terraform-docs/terraform-docs:0.16.0 markdown /terraform-docs > doc.md 62``` 63 64{{< alert type="primary" >}} 65Docker tag `latest` refers to _latest_ stable released version and `edge` refers 66to HEAD of `master` at any given point in time. And any named version tags are 67identical to the official GitHub releases without leading `v`. 68{{< /alert >}} 69 70## Pre-compiled Binary 71 72Stable binaries are available on the GitHub [Release] page. To install, download 73the file for your platform from "Assets" and place it into your `$PATH`: 74 75```bash 76curl -sSLo ./terraform-docs.tar.gz https://terraform-docs.io/dl/v0.16.0/terraform-docs-v0.16.0-$(uname)-amd64.tar.gz 77tar -xzf terraform-docs.tar.gz 78chmod +x terraform-docs 79mv terraform-docs /some-dir-in-your-PATH/terraform-docs 80``` 81 82{{< alert type="primary" >}} 83Windows releases are in `ZIP` format. 84{{< /alert >}} 85 86## Go Users 87 88The latest version can be installed using `go install` or `go get`: 89 90```bash 91# go1.17+ 92go install github.com/terraform-docs/terraform-docs@v0.16.0 93``` 94 95```bash 96# go1.16 97GO111MODULE="on" go get github.com/terraform-docs/terraform-docs@v0.16.0 98``` 99 100{{< alert type="warning" >}} 101To download any version **before** `v0.9.1` (inclusive) you need to use to 102old module namespace (`segmentio`): 103{{< /alert >}} 104 105```bash 106# only for v0.9.1 and before 107GO111MODULE="on" go get github.com/segmentio/terraform-docs@v0.9.1 108``` 109 110{{< alert type="primary" >}} 111Please use the latest Go to do this, minimum `go1.16` is required. 112{{< /alert >}} 113 114This will put `terraform-docs` in `$(go env GOPATH)/bin`. If you encounter the error 115`terraform-docs: command not found` after installation then you may need to either add 116that directory to your `$PATH` as shown [here] or do a manual installation by cloning 117the repo and run `make build` from the repository which will put `terraform-docs` in: 118 119```bash 120$(go env GOPATH)/src/github.com/terraform-docs/terraform-docs/bin/$(uname | tr '[:upper:]' '[:lower:]')-amd64/terraform-docs 121``` 122 123## Code Completion 124 125The code completion for `bash` or `zsh` can be installed as follow. Note that shell 126auto-completion is not available on Windows platform. 127 128### bash 129 130```bash 131terraform-docs completion bash > ~/.terraform-docs-completion 132source ~/.terraform-docs-completion 133 134# or the one-liner below 135 136source <(terraform-docs completion bash) 137``` 138 139### zsh 140 141```bash 142terraform-docs completion zsh > /usr/local/share/zsh/site-functions/_terraform-docs 143autoload -U compinit && compinit 144``` 145 146To make this change permanent, the above commands can be added to `~/.profile` file. 147 148[Chocolatey]: https://www.chocolatey.org 149[Homebrew]: https://brew.sh 150[Release]: https://github.com/terraform-docs/terraform-docs/releases 151[Scoop]: https://scoop.sh/ 152