Skip to content

Commit b65ef38

Browse files
authored
mix: Add MIX_INSTALL_FORCE environment variable support (#11337)
1 parent c799fcd commit b65ef38

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

lib/mix/lib/mix.ex

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ defmodule Mix do
302302
* `MIX_HOME` - path to Mix's home directory, stores configuration files and scripts used by Mix
303303
(default: `~/.mix`)
304304
* `MIX_INSTALL_DIR` - (since v1.12.0) specifies directory where `Mix.install/2` keeps
305-
installs cache
305+
* `MIX_INSTALL_FORCE` - (since v1.13.0) runs `Mix.install/2` with empty install cache
306306
* `MIX_PATH` - appends extra code paths
307307
* `MIX_QUIET` - does not print information messages to the terminal
308308
* `MIX_REBAR` - path to rebar command that overrides the one Mix installs
@@ -318,9 +318,7 @@ defmodule Mix do
318318
Environment variables that are not meant to hold a value (and act basically as
319319
flags) should be set to either `1` or `true`, for example:
320320
321-
```bash
322-
$ MIX_DEBUG=1 mix compile
323-
```
321+
$ MIX_DEBUG=1 mix compile
324322
"""
325323

326324
@mix_install_project __MODULE__.InstallProject
@@ -550,8 +548,9 @@ defmodule Mix do
550548
551549
## Options
552550
553-
* `:force` - if `true`, removes install cache. This is useful when you want
554-
to update your dependencies or your install got into an inconsistent state
551+
* `:force` - if `true`, runs with empty install cache. This is useful when you want
552+
to update your dependencies or your install got into an inconsistent state.
553+
To use this option, you can also set the `MIX_INSTALL_FORCE` environment variable.
555554
(Default: `false`)
556555
557556
* `:verbose` - if `true`, prints additional debugging information
@@ -670,7 +669,7 @@ defmodule Mix do
670669
|> :erlang.md5()
671670
|> Base.encode16(case: :lower)
672671

673-
force? = !!opts[:force]
672+
force? = System.get_env("MIX_INSTALL_FORCE") in ["1", "true"] or !!opts[:force]
674673

675674
case Mix.State.get(:installed) do
676675
nil ->

man/mix.1

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@ are not enough to solve the problem.
9797
path to Mix's home directory, stores configuration files and scripts used by Mix
9898
.It MIX_INSTALL_DIR
9999
Specifies directory where Mix.install/2 keeps installs cache
100+
.It MIX_INSTALL_FORCE
101+
Runs Mix.install/2 with empty install cache
100102
.It Ev MIX_PATH
101103
Allows expanding the code path. If the MIX_PATH environment variable has a value which consists of multiple paths, they must be colon-separated
102104
.Pq for Unix-like operating systems

0 commit comments

Comments
 (0)