Skip to content

Commit aa9c933

Browse files
author
José Valim
committed
Provide iex -S mix instead of mix iex
In order for iex to work reliably, we need it to pass special parameters to the Erlang VM. Therefore, it cannot be started via a regular Elixir script, as in `mix iex`. Therefore, we need to use `iex -S mix` which first boots iex and then run the given mix commands. Closes #692
1 parent a3d1ee6 commit aa9c933

File tree

8 files changed

+13
-53
lines changed

8 files changed

+13
-53
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
* [File] Deprecate path related functions in favor of the module `Path`
3131
* [Kernel] The `/>` operator has been deprecated in favor of `|>`
3232
* [Mix] `Mix.Project.sources` is deprecated in favor of `Mix.Project.config_files`
33+
* [Mix] `mix iex` is no longer functional, please use `iex -S mix`
3334
* [OptionParser] `:flags` option was deprecated in favor of `:switches` to support many types
3435

3536
# v0.7.2 (2012-12-04)

bin/mix

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,3 @@
1-
#!/bin/sh
2-
readlink_f () {
3-
cd "$(dirname "$1")" > /dev/null
4-
local filename="$(basename "$1")"
5-
if [ -h "$filename" ]; then
6-
readlink_f "$(readlink "$filename")"
7-
else
8-
echo "`pwd -P`/$filename"
9-
fi
10-
}
11-
12-
SELF=$(readlink_f "$0")
13-
SCRIPT_PATH=$(dirname "$SELF")
14-
EXECUTABLE="elixir"
15-
16-
if [ "$1" = "iex" ]; then EXECUTABLE="iex"; fi
17-
exec "$SCRIPT_PATH"/$EXECUTABLE -e "Mix.start; Mix.CLI.run" -- "$@"
1+
#!/usr/bin/env elixir
2+
Mix.start
3+
Mix.CLI.run

bin/mix.bat

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1 @@
1-
@echo off
2-
if "%1" == "iex" (
3-
goto iex
4-
) else (
5-
goto elixir
6-
)
7-
:iex
8-
call "%~dp0\iex.bat" -e "Mix.start" -e "Mix.CLI.run" -- %*
9-
:elixir
10-
call "%~dp0\elixir.bat" -e "Mix.start" -e "Mix.CLI.run" -- %*
1+
call "%~dp0\elixir.bat" "%~dp0\mix" %*

lib/mix/lib/mix/cli.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ defmodule Mix.CLI do
3434
end
3535

3636
defp get_task([]) do
37-
{ Mix.project[:default] || "test", [] }
37+
{ Mix.project[:default_task] || "compile", [] }
3838
end
3939

4040
defp run_task(name, args) do

lib/mix/lib/mix/project.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ defmodule Mix.Project do
138138
[ compile_path: "ebin",
139139
elixirc_exts: [:ex],
140140
default_env: [test: :test],
141-
default_task: "test",
141+
default_task: "compile",
142142
deps_path: "deps",
143143
erlc_paths: ["src"],
144144
lockfile: "mix.lock",

lib/mix/lib/mix/tasks/iex.ex

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,9 @@
11
defmodule Mix.Tasks.Iex do
22
use Mix.Task
3+
@moduledoc false
34

4-
@shortdoc "Start IEx with your project's settings"
5-
6-
@moduledoc """
7-
Starts an iex repl with your project settings.
8-
9-
Before starting IEx, it invokes the prepare task
10-
which defaults to compile and load your project.
11-
12-
## Command line options
13-
14-
* `--no-compile` - do not compile even if files require compilation;
15-
* `--no-start` - do not start applications after compilation;
16-
17-
"""
18-
def run(args) do
19-
Mix.Task.run Mix.project[:prepare_task], args
20-
21-
unless IEx.started? do
22-
raise Mix.Error, message: "could not start IEx. Due to booting constraints, " <>
23-
"IEx needs to be started on its own, like `mix iex` and it cannot be mixed " <>
24-
"with other tasks as in `mix do compile, iex`"
25-
end
5+
def run(_args) do
6+
raise Mix.Error, message: "mix iex is deprecated. Due to the VM constraints, " <>
7+
"IEx needs to be configured on boot. Use `iex -S mix` instead."
268
end
279
end

lib/mix/test/mix/cli_test.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ defmodule Mix.CLITest do
1414
in_fixture "custom_mixfile", fn ->
1515
output = mix ""
1616
assert File.regular?("ebin/Elixir-A.beam")
17-
assert output =~ %r"1 tests, 0 failures"
17+
assert output =~ %r"Compiled lib/a.ex"
1818
end
1919
end
2020

lib/mix/test/test_helper.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ defmodule MixTest.Case do
6666
end
6767

6868
def mix(args) do
69-
System.cmd "#{mix_executable} #{args}"
69+
System.cmd "#{elixir_executable} #{mix_executable} #{args}"
7070
end
7171

7272
def mix_executable do

0 commit comments

Comments
 (0)