[Proposal] mix build task

66 views
Skip to first unread message

Jonathan Arnett

unread,
Jul 13, 2023, 10:08:55 AM7/13/23
to elixir-lang-core
When I first clone an Elixir repository, usually the first thing I do is run `mix do deps.get, compile`.  It gets the job done, but it's a bit verbose.  Build tools in other languages (e.g. Rust's cargo, Haskell's stack, Gleam's gleam) have a "build" command that both pulls dependencies and compiles the app.  The proposed "build" command for mix would functionally be the same running `mix do deps.get, compile`, just in a smaller package.

I realize that I can make such an alias in my own projects, and I have, but I wonder if this would be useful for the larger Elixir community.

Christopher Keele

unread,
Jul 13, 2023, 3:17:14 PM7/13/23
to elixir-lang-core
I'd make the counter-argument: mix is a build tool, but not your build; that's something you should define for your project.

In pretty much all of my projects, I find myself writing a `mix build` alias, as a high-level one-stop-shop command, but it looks very different for each project—my Bakeware CLI application builds look very different from my phoenix umbrella web application build with a custom auto-asset-vendoring pipeline.

Perhaps simply having `mix new` create a default alias for `mix build` would work here? I'm very against prescribing what it means to build a project, but this approach would encourage a common idiom across mix projects as well as giving developers a jumping-off-point for when their build's complexity grows.

Jonathan Arnett

unread,
Jul 13, 2023, 3:21:52 PM7/13/23
to elixir-lang-core
I'm definitely open to generating a default alias.

Andrea Leopardi

unread,
Jul 14, 2023, 3:11:49 AM7/14/23
to elixir-l...@googlegroups.com
I personally like the idea of a mix build alias defined by mix new. The reason is that, while mix build is usually different for different projects, I like the idea of standardizing on the terminology "build".

-- 
You received this message because you are subscribed to the Google Groups "elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-co...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/7da02486-b925-42b6-90e7-4f06c667417fn%40googlegroups.com.

José Valim

unread,
Jul 14, 2023, 4:00:23 AM7/14/23
to elixir-l...@googlegroups.com
Phoenix standardized on setup, but it does not include the compile command. Not sure how useful build with compile is, if you run mix test instead of mix compile, build won’t help it.

Christopher Keele

unread,
Jul 14, 2023, 5:17:39 AM7/14/23
to elixir-l...@googlegroups.com
> Not sure how useful build with compile is, if you run mix test instead of mix compile, build won’t help it.

> Phoenix standardized on setup, but it does not include the compile command. 

I think a standard `mix build` interface would be most useful for:

- People new to Elixir just checking out a project from source and trying to see if it compiles, using familiar semantics from other langs
- People checking out a project from source with compilable deliverables, like a CLI executable, which is beyond the purview of most Phoenix applications

I'm not really arguing for it, I think these use cases are rare. But if we entertain it, I'd rather amend the proposal with a `build: ["deps.get", "compile"]`  alias in project templates rather than a hardcoded command.

You received this message because you are subscribed to a topic in the Google Groups "elixir-lang-core" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/elixir-lang-core/taoD_hFQd1Y/unsubscribe.
To unsubscribe from this group and all its topics, send an email to elixir-lang-co...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/CAGnRm4%2BYwRB%2B11WP-EiqUWt%2ButiZqMZQmGW7vZa47pNp6Ec%2Bhw%40mail.gmail.com.

Wojtek Mach

unread,
Jul 14, 2023, 5:43:25 AM7/14/23
to elixir-l...@googlegroups.com

- People new to Elixir just checking out a project from source and trying to see if it compiles, using familiar semantics from other langs

I’d love to hear from actual users because to _me_ this feels like a bit of a stretch. I think people don’t want to see whether something compiles, they want to see how something works, i.e. `mix deps.get && iex -S mix`. From that POV, I think it’d be really cool if we could jump to any Elixir project and call something like `iex -S mix` and be good to go. `mix setup && iex -S mix` is acceptable imo, but one invocation would be even better.

Jim Freeze

unread,
Jul 14, 2023, 10:26:45 AM7/14/23
to elixir-l...@googlegroups.com
On Fri, Jul 14, 2023 at 4:17 AM Christopher Keele <christ...@gmail.com> wrote:
I think a standard `mix build` interface would be most useful for:

- People new to Elixir just checking out a project from source and trying to see if it compiles, using familiar semantics from other langs
- People checking out a project from source with compilable deliverables, like a CLI executable, which is beyond the purview of most Phoenix applications

Hi, Chris.

I'll give a counter opinion on `mix build`. I find it confusing because I don't know what it does. 
I used zig for a while and the most confusing thing about their environment was the build command.

If `mix build` was added today, I would end up having to read mix.exs every time to remember what it did.

 I'm not sure a standard alias will be helpful if everyone ends up having to customize it anyway and then there is no shared understanding of what `mix build` means.

Jim

Josh Adams

unread,
Jul 14, 2023, 10:37:16 AM7/14/23
to elixir-l...@googlegroups.com
In general, my happy place is a Makefile anyway. `make` ought to do what I would want this for and is more flexible. t: am curmudgeon

Andrea Leopardi

unread,
Jul 14, 2023, 11:05:13 AM7/14/23
to elixir-l...@googlegroups.com
I'd be super ok with "mix setup" as a standard-ish name, to be clear. :) And I think "mix setup" followed by "iex" or whatever would be good too.

On 14 Jul 2023, at 11:43, Wojtek Mach <woj...@wojtekmach.pl> wrote:


- People new to Elixir just checking out a project from source and trying to see if it compiles, using familiar semantics from other langs

I’d love to hear from actual users because to _me_ this feels like a bit of a stretch. I think people don’t want to see whether something compiles, they want to see how something works, i.e. `mix deps.get && iex -S mix`. From that POV, I think it’d be really cool if we could jump to any Elixir project and call something like `iex -S mix` and be good to go. `mix setup && iex -S mix` is acceptable imo, but one invocation would be even better.

--
You received this message because you are subscribed to the Google Groups "elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-co...@googlegroups.com.

Wojtek Mach

unread,
Jul 14, 2023, 11:12:17 AM7/14/23
to elixir-l...@googlegroups.com
I just realised that for this alias:

setup: [“deps.get”, “app.start”]

Running:

$ iex -S mix setup

Just works™. Make of that what you will. :)

Jonathan Arnett

unread,
Jul 14, 2023, 8:36:33 PM7/14/23
to elixir-lang-core
I ultimately don't care if the name is "setup" or "build", but I do wonder if compilation fits conceptually under the name "setup".

To expound on my original idea, I was thinking of having a command that I would run both on the first pull, but also fairly regularly while working on the project.  This is also the flow with Rust, Haskell, Zig, etc who were mentioned before.  In these ecosystems, whether you're adding a dependency or just recompiling your app, you use the same command.  This flow has a nice simplicity to it.

In reference to both the comment about Makefiles and also Wojtek's thoughts around `iex -S mix`, one can define a default task to be run for your project when just running `$ mix`.  One could define a `setup` task as mentioned, specify `default_task: "setup"` in your mix.exs, and then when running `$ iex -S mix`, the app would first set itself up, then give you an IEx shell.  I'm not sure if this is a good default or not, but it is a fun concept, and something I may do in my projects.

Jason Axelson

unread,
Jul 22, 2023, 4:45:11 PM7/22/23
to elixir-l...@googlegroups.com
I could argue that `mix setup` already fulfills this role due to being included in phoenix projects by default with the following aliases:

      setup: ["deps.get", "ecto.setup", "assets.setup", "assets.build"],
      "ecto.setup": ["ecto.create", "ecto.migrate", "run priv/repo/seeds.exs"],

On phoenix applications I run `mix setup` every time I start my server via `mix setup && iex -S mix phx.server` and I expand `mix setup` with whatever setup a particular Phoenix application needs.

I'd be glad to see this pattern picked up more in the community but I'm not sure we need to change anything in core for it.

Jason

--
You received this message because you are subscribed to the Google Groups "elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-co...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages