Benjamin-Philip
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.
Trending in Discussions
Other Trending Topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixirconf-us
- #ai
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #hex
- #security










Showing Posts 1 to 10- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
NobbZ
One of the main reasons is that such a task wouldn’t be able to work reliably, as the
mix.exsis code, and not structured data.Someone experimented with a tool that has written and read an external deps file.
Not sure if this is still findable on GitHub or perhaps even was released on hex.
Though AFAIK it never left the “experimental” status and is also considered problematic as it needs to be installed “globally”
LostKobrakai
The tricky question is: where should it be added exactly? Given mix.exs is code there could be any mounts of logic in the list of deps. Even the default of having dependencies listed in a helper function is just convention, but not in any way enforced.
derek-zhou
Let’s not go down the route of node.js. I absolutely hate it when
npm installchange mypackage.jsonfile and mess up the indentation.Having a file that regularly needs to be modified by human and machine is asking for trouble.
dorgan
On top of what’s already been said, the amount of work you need to do to correctly insert the new dependency without messing up the rest of the code is a bit non trivial. Even if we make it work only in the case of the
defp deps do ...convention, regex is unreliable and doing it by playing with the ast is quite a bit of work, even for this single use case. It is doable though.Regarding the “deps could be anywhere besides
deps”, this is one option:lud
To me the best proposal would be to add a trailing comma in the one-click copy version on hex.pm. That’s it.
dimitarvp
IMO getting something like
mix deps.addto work reliably, we need a first-class engine for modifying Elixir code. @dorgan here is working on it.Benjamin-Philip
I think we can only follow the convention of adding a dependency to the
depsfunction.When it comes to actually editing the file, the solution that came to mind is using some sort of regex. This though is unreliable albeit easy. I think using the AST is much more reliable, but I am not sure how you would do so. Any resources on editing the code programmatically is much appreciated.
stefanchrobot
I think the only way to reliably make this work is to introduce a plain data file - so something like
deps.json. Everything else has the issue of having the need to evaluate the code. Not sure what are the exact requirements of.formatter.exsare, but it seems you can throw anifinto that file and it just works. Same goes formix.exsand a potentialdeps.exs.And if you’re going to make it work in limited number of use cases - which also probably covers something like 90% of occurences - I think it makes sense to add it as an external package. You could
mix installit just once and then just have a global task likephx.new.hauleth
Few examples of
mix.exsfor you to deduce how you would like to add the new dependency:Benjamin-Philip
Thank you!