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:
-
Why are
deps.addproposals rejected -
What do you think of this proposal ?
PS: This is my first post. Apologies if I violated any code of conduct.
Most Liked
ericmj
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
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
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.
Popular in Discussions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance









