Benjamin-Philip

Benjamin-Philip

Why doesn't the Elixir core team accept `mix deps.add` proposals?

I’m thinking of submitting yet another mix deps.add proposal. It has gotten to the point where I feel that such a simple and repetitive task could easily be shortened by adding a mix task for it. However, I have noticed that the Core team ignores/rejects such proposals. I tried look through the mails of the past 2 years and I haven’t found any explanation.

Here’s what I am going to propose:

mix deps.add will only be used for editing the Mixfile and adding a task. Added dependencies are only fetched with deps.get
By default, we would supply the package name, and we will add the latest version. For example:

mix deps.add ecto

Will add

{:ecto, "~> 3.6"}

at this point of time.

It will have the options of --version (to specify version) --git(to specify git repository) and --github (to specify GitHub repository)

So 2 things:

  1. Why are deps.add proposals rejected

  2. What do you think of this proposal ?

PS: This is my first post. Apologies if I violated any code of conduct.

Most Liked

ericmj

ericmj

Elixir Core Team

If adding mix deps.add means you have to list your dependencies in a separate file or have to structure them in a special way, then it’s not a good solution. One feature in the language shouldn’t limit other features.

As @LostKobrakai already said mix hex.info shows the configuration you can copy-paste into mix.exs:

> mix hex.info jason
A blazing fast JSON parser and generator in pure Elixir.

Config: {:jason, "~> 1.2"}
Releases: 1.2.2, 1.2.1, 1.2.0, 1.1.2, 1.1.1, 1.1.0, 1.0.1, 1.0.0, ...

Licenses: Apache-2.0
Links:
  GitHub: https://github.com/michalmuskala/jason

The single extra step of pasting the dependency config into mix.exs is not worth losing the flexibility of being able to configure dependencies using code.

hauleth

hauleth

Few examples of mix.exs for you to deduce how you would like to add the new dependency:

defmodule Foo.Mixfile do
  use Mix.Project

  def project, do: [app: :foo, version: "0.0.1"]
end
defmodule Foo.Mixfile do
  use Mix.Project

  def project do
    [app: :foo, version: "0.0.1"]
  end
end
defmodule Foo.Mixfile do
  use Mix.Project

  def project do
    [app: :foo, version: "0.0.1", deps: [{:mydep, ">= 0.0.0"}]]
  end
end
defmodule Foo.Mixfile do
  use Mix.Project

  def project do
    [
      app: :foo,
      version: "0.0.1",
      deps: foos()
    ]
  end

  defp foos, do: []
end
defmodule Foo.Mixfile do
  use Mix.Project

  def project do
    [
      app: :foo,
      version: "0.0.1",
      deps: deps(Mix.env())
    ]
  end

  defp deps(:dev) do
    []
  end

  defp deps(:test) do
    [{:benchee, ">= 0.0.0"}]
  end
end
defmodule Foo.Mixfile do
  use Mix.Project

  def project do
    [
      app: :foo,
      version: "0.0.1",
      deps: deps(System.get_env("BENCH"))
    ]
  end

  defp deps(nil) do
    []
  end

  defp deps(_) do
    [{:benchee, ">= 0.0.0"}]
  end
end
defmodule Foo.Mixfile do
  use Mix.Project

  def project do
    [
      app: :foo,
      version: "0.0.1",
      deps: deps()
    ]
  end

  defp deps do
    [{:foo, ">= 0.0.0"} | more_deps()]
  end

  defp more_deps() do
    [{:bar, ">= 0.0.0"}]
  end
end
defmodule Foo.Mixfile do
  use Mix.Project

  def project do
    [
      app: :foo,
      version: "0.0.1",
      deps: deps(System.get_env("BENCH"))
    ]
  end

  defp deps(nil) do
    []
  end

  defp deps(_) do
    [{:benchee, ">= 0.0.0"}]
  end
end
defmodule Foo.Mixfile do
  use Mix.Project

  @deps [{:foo, ">= 0.0.0"}]

  def project do
    [
      app: :foo,
      version: "0.0.1",
      deps: @deps
    ]
  end
end
defmodule WhyNot do
  def deps, do: [{:foo, ">= 0.0.0"}]
end

defmodule Foo.Mixfile do
  use Mix.Project

  def project do
    [
      app: :foo,
      version: "0.0.1",
      deps: WhyNot.deps()
    ]
  end
end
derek-zhou

derek-zhou

Let’s not go down the route of node.js. I absolutely hate it when npm install change my package.json file and mess up the indentation.

Having a file that regularly needs to be modified by human and machine is asking for trouble.

12
Post #4

Where Next?

Popular in Discussions Top

andre1sk
A big advantage to Elixir is all the distributed goodness but for many applications running on multiple nodes having integrated Etcd, Zoo...
New
Fl4m3Ph03n1x
Background A few days ago I was listening to The future of Elixir from Elixir Talks, with Dave Thomas (@pragdave ) and Brian Mitchell. I...
New
WolfDan
After doing a port from a c++ library to my project in phoenix I’ve seen that I need a faster way to run this algorithm and I found this ...
New
crispinb
On reading dhh’s latest The One Person Framework it strikes me that Phoenix with LiveView is already pretty much this. However, never hav...
New
AlexMcConnell
The reason that Rails is as popular as it is is because it’s very easy for relatively inexperienced developers to get a lot of work done....
588 19568 166
New
marciol
Please, let me know if this kind of discussion already took place in another topic . Hi all, how do you consider if is better to build ...
New
eteeselink
Hi all, In the last days, two things happened: A blog post titled “They might never tell you it’s broken” made the rounds. It’s about ...
New
ben-pr-p
In general I’ve been sticking to this community style guide GitHub - christopheradams/elixir_style_guide: A community driven style guide ...
New
scouten
I’m looking for a host for the server part of a small (personal) side project that I’m working on. It’s currently written in Node.js and ...
New
opsb
We’re considering our architecture from a viewpoint of scaling our traffic heavily over the next 6 months. Our current deployment is runn...
New

Other popular topics Top

TunkShif
This post is an instruction guide to help you setup your Neovim for Elixir development from scratch. It includes general information on h...
274 41539 114
New
electic
Hi, I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
jononomo
I am trying to figure out how Mix knows whether the environment is test, dev, or prod – where is this set? Thanks.
New
josevalim
Hi everyone, One of the features added to Elixir early on to help integration with Erlang code was the idea of overridable function defi...
New
Lily
In templates/appointment/index.html.eex: <%= for appointment <- @appointments do %> <tr> <td><%= appoi...
New
dokuzbir
I want to highlight html closing tags when i click a html tag. That works in .html files but doesnt work for html.eex templates. How can...
New
RisingFromAshes
I’ve read in another post that it may be possible with a router helper - but I couldn’t find an appropriate one, and tbh, I’m still just ...
New
Qqwy
Original source of discussion: This topic on the Pragmatic Programmers’ Functional Web Development with Elixir, OTP, and Phoenix forum. ...
New
WestKeys
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New
Qqwy
Update: How to use the Blogs & Podcasts section You can post links to your blog posts or podcasts either in one of the Official Blog...
3271 126479 1222
New

We're in Beta

About us Mission Statement