"Right" way to update mix.lock after removing a dependency?

9,118 views
Skip to first unread message

hen...@nyh.se

unread,
Jun 21, 2015, 5:09:24 AM6/21/15
to elixir-l...@googlegroups.com
I removed a dependency from mix.exs and ran "mix deps.get" but the removed dependency was still listed in mix.lock.

I had(?) to do

    mix deps.unlock --all  # Make mix.lock empty
    mix deps.get  # Populate it again – in some cases with newer versions

for this to happen. And also perhaps

    mix deps.clean --unused

to remove the files from disk.

My mental model of this is based on Bundler for Ruby. With Bundler, the "bundle install" (or just "bundle") command will download any missing dependencies/versions AND get rid of removed ones.

What is the recommended way to work with mix in this regard? What should I do when I remove a dependency from mix.exs?

Eric Meadows-Jönsson

unread,
Jun 21, 2015, 5:14:18 AM6/21/15
to elixir-l...@googlegroups.com
Run mix.deps.clean --unused --unlock. Mix will never remove dependencies from the lock unless explicitly told. This is because you can use subset of your dependencies depending on your code in mix.exs or dependening on the mix environment (dev, test, prod). It would be unexpected to automatically remove things from the lock because you changed environment.

--
You received this message because you are subscribed to the Google Groups "elixir-lang-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-ta...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-talk/aa4c48d2-0f96-4d68-8184-c2deac6ff768%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Eric Meadows-Jönsson

José Valim

unread,
Jun 21, 2015, 5:23:09 AM6/21/15
to elixir-l...@googlegroups.com
Or "mix deps.unlock dep1 dep2" or "mix deps.unlock --unused". It is also worth mentioning that a dependency that was not cleaned will have files at deps/dep_name but it won't be part of the _build.



José Valim
Skype: jv.ptec
Founder and Director of R&D

hen...@nyh.se

unread,
Jun 21, 2015, 5:38:56 AM6/21/15
to elixir-l...@googlegroups.com
Eric, José, thank you!

That makes sense.
Reply all
Reply to author
Forward
0 new messages