简体   繁体   中英

mix deps error when 2 libraries share the same dependancy and require different versions

I am having issues resolving my phoenix app's dependencies:

My mix.exs file has:

{:phoenix, "~> 1.4.0"},
{:phoenix_pubsub, "~> 1.1"},
{:phoenix_ecto, "~> 4.0"},
{:ecto_sql, "~> 3.0"},
{:postgrex, ">= 0.0.0"},
{:phoenix_html, "~> 2.11"},
{:phoenix_live_reload, "~> 1.2", only: :dev},
{:gettext, "~> 0.11"},
{:jason, "~> 1.0"},
{:plug_cowboy, "~> 2.0"},
{:redix, ">= 0.0.0"},
{:extwitter, "~> 0.9.3"},      
{:timex, "~> 3.0"},
{:corsica, "~> 1.0"},
{:cachex, "~> 3.1"},
{:bamboo, "~> 1.1"},
{:bamboo_ses, "~> 0.1.0"},
{:comeonin, "~> 4.1"},
{:bcrypt_elixir, "~> 1.1"},
{:ex_machina, "~> 2.2", only: :test}

I then added this stripe library:

 {:stripity_stripe, "~> 2.0.0"},

Now when I perform a deps.get I see this error:

Failed to use "hackney" (versions 1.13.0 to 1.15.1) because bamboo (versions 1.1.0 and 1.2.0) requires >= 1.13.0 stripity_stripe (versions 2.0.0 and 2.0.1) requires ~> 1.12.1

** (Mix) Hex dependency resolution failed, change the version requirements of your dependencies or unlock them (by using mix deps.update or mix deps.unlock). If you are unable to resolve the conflicts you can try overriding with {:dependency, "~> 1.0", override: true}

I already did this:

mix clean
rm mix.lock
mix deps.get

How do I use that override options? How will this work if 2 libraries need different versions of a shared dependency?

I found a similar question on the elixir forum . Relevant quotes:

You can't have multiple versions of the same application running at the same time

and

A single module can only exist in one version on the VM. So this gives restrictions on the application structure. This basically means everybody needs to agree on a single version.

Also, the docs for :override state:

if set to true the dependency will override any other definitions of itself by other dependencies

This doesn't sound like what you want, because you will just be forcing stripity_stripe 2.0.0 to use a different version to what it expects.

It looks like you need to find a version of stripity_stripe that depends on versions of hackney that are also supported by :bamboo, "~> 1.1" .

So,

{:bamboo, "~> 1.1"},
{:stripity_stripe, "~> 2.2.2"}

looks good. I tested this with mix deps.get and it was fine.

In your scenario if possible you can use

{:stripity_stripe, "~> 2.2.2"}

Or you should be able to add hackney as a dependency and apply override: true .

{:hackney, "~> 1.13", override: true}

Hope that helps

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM