github.com/hashicorp/packer@v1.14.3/website/content/docs/commands/init.mdx (about) 1 --- 2 description: | 3 The `packer init` command downloads and installs the plugins specified in a Packer template. 4 page_title: packer init command reference 5 --- 6 7 # `packer init` command reference 8 9 <Note> 10 11 Starting August 1st, 2025, the source for many official HashiCorp-maintained Packer plugins is moving from GitHub releases to the official HashiCorp release site, [releases.hashicorp.com](https://releases.hashicorp.com). Refer to [Install HashiCorp-maintained plugins](/packer/docs/plugins/install#install-hashicorp-maintained-plugins) for more information. 12 13 </Note> 14 15 16 The `packer init` command initializes Packer according to an HCL template configuration. Refer to [Installing Plugins](/packer/docs/plugins/install) for additional information about installing plugins. 17 18 ## Description 19 20 Use the `packer init` command to download and install plugins according to the `required_plugins` block in Packer templates written in HCL. Refer to [Specifying plugin requirements](/packer/docs/templates/hcl_templates/blocks/packer#specifying-plugin-requirements) in the template configuration reference for additional information about configuring the `required_plugins` block. 21 22 Legacy JSON templates are not supported. You can convert your JSON template files to HCL using the [hcl2_upgrade](/packer/docs/commands/hcl2_upgrade) command. 23 24 We recommend running the `packer init` command as the first step when working with a new or existing template. You can run the command multiple times. Subsequent runs may produce errors, but the command never deletes already-installed plugins. 25 26 ### Third-party plugin verification 27 28 We recommend that you vet and verify any third-party plugins you want to install. 29 30 ### Installation location 31 32 By default, Packer installs plugins into the plugins directory at `$HOME/.config/packer/plugins` on Unix and `%APPDATA%\packer.d\plugins` on Windows, but you can specify a different directory using the `PACKER_PLUGIN_PATH` environment variable. Refer to the [Packer configuration reference](/packer/docs/configure) for additional information. 33 34 ## Usage 35 36 Use the following syntax to run the `packer init` command: 37 38 ```shell-session 39 $ packer init <path-to-template> 40 ``` 41 The command will process any template file that ends with `pkr.hcl`. 42 43 The template must contain all dependencies when running the command on a single template file. The command fails if the template is intended to be built as a bundle of partials. 44 45 For variable definitions, it is recommended to use the extensions `.pkrvars.hcl` or `.auto.pkrvars.hcl`. When you run `packer init` in the directory, these variable definition files will be automatically excluded from processing. 46 47 ## Examples 48 49 The following example installs the plugins specified in a template from the current directory: 50 51 ```shell-session 52 $ packer init . 53 ``` 54 55 The following example installs the plugins specified in a template named `template.pkr.hcl` from the current directory: 56 ```shell-session 57 $ packer init template.pkr.hcl 58 ``` 59 60 The following example installs the plugins specified in the `builds/foo/` directory: 61 62 ```shell-session 63 $ packer init builds/foo/. 64 ``` 65 66 The following example installs the plugins specified in a template from the `builds/foo/template.pkr.hcl` path: 67 68 ```shell-session 69 $ packer init builds/foo/template.pkr.hcl 70 ``` 71 72 ## Arguments 73 74 You can pass the following arguments: 75 76 - Packer template: Specify the path to either an HCL2 template or a directory containing at least one valid HCL2 template and related dependencies. 77 78 ## Options 79 80 - `-upgrade`: Use this option to upgrade plugins that are already installed to the latest available version. Packer upgrades to the latest version in accordance with the version constraints specified in the template. 81 - `-force`: Use this option to force Packer to reinstall plugins.