# `mix local.hex`
[🔗](https://github.com/elixir-lang/elixir/blob/v1.20.4/lib/mix/lib/mix/tasks/local.hex.ex#L5)

Installs Hex locally.

    $ mix local.hex [version]

By default the latest compatible version of Hex will be installed, unless
`version` is specified.

If installing a precompiled Hex does not work, you can compile and install
Hex directly with this command:

    $ mix archive.install github hexpm/hex branch latest

## Command line options

  * `--force` - forces installation without a shell prompt; primarily
    intended for automation in build systems like `make`

  * `--if-missing` - performs installation only if Hex is not installed yet;
    intended to avoid repeatedly reinstalling Hex in automation when a script
    may be run multiple times

If both options are set, the shell prompt is skipped and Hex is not
re-installed if it was already installed.

## Mirrors

If you want to change the [default mirror](https://builds.hex.pm)
used for fetching Hex, set the `HEX_BUILDS_URL` environment variable.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
