odohMei7

odohMei7

Dependency error: Phoenix with gun

I am new to phoenix and want to use it with gun to subscribe to websockets. But when I try this in a phoenix project, I get a dependency error. As a minimal example do the following:

$ mix phx.new --version
Phoenix v1.5.3
$ mix phx.new test --no-ecto
[...]

Then I add gun to the dependencies:

  defp deps do
    [
      {:phoenix, "~> 1.5.3"},
      {:phoenix_html, "~> 2.11"},
      {:phoenix_live_reload, "~> 1.2", only: :dev},
      {:phoenix_live_dashboard, "~> 0.2.0"},
      {:telemetry_metrics, "~> 0.4"},
      {:telemetry_poller, "~> 0.4"},
      {:gettext, "~> 0.11"},
      {:jason, "~> 1.0"},
      {:plug_cowboy, "~> 2.0"},
      {:gun, "~> 1.3.2"},
    ]
  end

But when I do mix deps.get I get the following error:

Resolving Hex dependencies...

Failed to use "cowlib" because
  gun (version 1.3.2) requires ~> 2.6.0
  mix.lock specifies 2.9.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}

What should I do? Thanks in advance.

Marked As Solved

benwilson512

benwilson512

Author of Craft GraphQL APIs in Elixir with Absinthe

No, that is not possible, Elixir can only load one version of code for a given application. However you may be in luck, it looks like the version of gun on github supports the latest cowlib. You could try doing:

 {:gun, github: "ninenines/gun"},

Also Liked

LostKobrakai

LostKobrakai

This is not a bug. You installed phoenix, which then fetched the latest version of cowlib and locks the version in mix.lock (this happens for all your dependencies). gun however needs an earlier version of cowlib. You’re however unlikely to be using cowlib directly (transitive dependency) and it seems non of your direct dependencies actually conflicts with the version constraint of gun, so you should be able to safely do mix deps.unlock cowlib, mix deps.get. This will remove the lock on the currently installed version of cowlib and allow mix to resolve the selected version under those new constraints with gun.

LostKobrakai

LostKobrakai

Mix automatically locks to git commits.

axelson

axelson

Scenic Core Team

I’m pretty sure that would only happen if you don’t commit your mix.lock file which you almost always should commit for elixir projects.

Last Post!

benwilson512

benwilson512

Author of Craft GraphQL APIs in Elixir with Absinthe

I think this is a perfectly fine stance to take, I just wanted to make sure that the OP was clear on how mix.lock works.

Where Next?

Popular in Questions Top

rms.mrcs
Hi, I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list. ...
New
vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New
openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
9mm
I am constructing a JSON object (map) and I need to conditionally set a field. I’m trying to write proper elixir-way code… and I’m at a l...
New
belgoros
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New
jerry
Good day to you all. I have been struggling to get a query involving like and ilike to work. Can anyone assist me on this, please? pro...
New
vrod
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors: [WARN] - (starship::utils): Executing command ...
New

Other popular topics Top

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 130286 1222
New
vertexbuffer
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
grych
Hi folks, Few months ago I have announced the proof-of-concept of the library to manipulate the browsers DOM objects directly from Elixi...
639 54006 488
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
nsuchy
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
gshaw
What is the idiomatic way of matching for not nil in Elixir? E.g., First way: defp halt_if_not_signed_in(conn, signed_in_account) when...
New

We're in Beta

About us Mission Statement