Elixir "Package not found in registry: :hackney" problem
Asked Answered
S

2

9

I am attempting to add coverage to my project, but keep running into problems.

I've attempted all the suggestions in the error message at the bottom of this listing.

I have a large project that I wish to add coverage for unittest, but all the coverage packages bomb similarly.

I started a clean project, "bug", with only the mix deps() addition so interference gets minimized.

Any help would be appreciated.

Versions:

rebar3 --version
rebar 3.13.2 on Erlang/OTP 22 Erts 10.4.3

elixir --version
Erlang/OTP 22 [erts-10.4.3] [source] [64-bit] [smp:12:12] [ds:12:12:10] [async-threads:1] [hipe]
Elixir 1.9.4 (compiled with Erlang/OTP 22)

erl --version
Erlang/OTP 22 [erts-10.4.3] [source] [64-bit] [smp:12:12] [ds:12:12:10] [async-threads:1] [hipe]
Eshell V10.4.3  (abort with ^G)

The mix.exs in deps

defp deps() do
  [
    #{:coverex, "~> 1.5", only: [:test], runtime: false},
    {:excoveralls, "~> 0.13.0", only: [:test], runtime: false},
    {:idna, "~> 6.0.1"},
  ]
end

I've used different versions of coverex and excoveralls but the results are the same.

I notice:

"Bad dependency version for httpoison (and others...)"

but I don't understand what to do about this either.

The error/warning messages appear to be related to the dependencies. Shouldn't dependencies resolve these themselves?

Here is the listing:

=> mix clean
=> mix deps.get
Resolving Hex dependencies...
Dependency resolution completed:
Unchanged:
  certifi 2.5.2
  excoveralls 0.13.0
  hackney 1.16.0
  idna 6.0.1         # Below it says idna 6.0.1 not found - why?
  jason 1.2.1
  metrics 1.0.1
  mimerl 1.2.0
  parse_trans 3.3.0
  ssl_verify_fun 1.1.6
  unicode_util_compat 0.5.0
All dependencies are up to date
Command completed
=> mix test  # Try to run default test on a new repo
===> Package idna-6.0.1 not found. Fetching registry updates and trying again...
===> Updating package registry...
===> Writing registry to /home/cecilm/.cache/rebar3/hex/default/registry
===> Generating package index...
===> [appsignal:1.6.2], Bad dependency version for httpoison: ~> 0.11 or ~> 1.0.
===> [appsignal:1.6.6-beta.1], Bad dependency version for httpoison: ~> 0.11 or ~> 1.0.
===> [appsignal:1.6.0], Bad dependency version for httpoison: ~> 0.11 or ~> 1.0.
===> [appsignal:1.7.0-alpha.4], Bad dependency version for httpoison: ~> 0.11 or ~> 1.0.
===> [appsignal:1.6.0-beta.1], Bad dependency version for httpoison: ~> 0.11 or ~> 1.0.
===> [appsignal:1.6.3], Bad dependency version for httpoison: ~> 0.11 or ~> 1.0.
===> [appsignal:1.7.0-alpha.3], Bad dependency version for httpoison: ~> 0.11 or ~> 1.0.
===> [batch_loader:0.1.0-beta.4], Bad dependency version for absinthe: ~> 1.4.0 or ~> 1.5.0-beta.
===> [prometheus_httpd:2.1.10], Bad dependency version for prometheus: ~> 3.5 or ~> 4.2.
===> [batch_loader:0.1.0-beta.5], Bad dependency version for absinthe: ~> 1.4.0 or ~> 1.5.0-beta.
===> [appsignal:1.7.0-alpha.2], Bad dependency version for httpoison: ~> 0.11 or ~> 1.0.
===> [appsignal:1.7.0-alpha.1], Bad dependency version for httpoison: ~> 0.11 or ~> 1.0.
===> [batch_loader:0.1.0-beta.6], Bad dependency version for absinthe: ~> 1.4.0 or ~> 1.5.0-beta.
===> [appsignal:1.12.0], Bad dependency version for decorator: ~> 1.2.3 or ~> 1.3.
===> [appsignal:1.6.1], Bad dependency version for httpoison: ~> 0.11 or ~> 1.0.
===> [appsignal:1.6.5], Bad dependency version for httpoison: ~> 0.11 or ~> 1.0.
===> [appsignal:1.6.6-beta.2], Bad dependency version for httpoison: ~> 0.11 or ~> 1.0.
===> [appsignal:1.6.6], Bad dependency version for httpoison: ~> 0.11 or ~> 1.0.
===> [appsignal:1.6.7], Bad dependency version for httpoison: ~> 0.11 or ~> 1.0.
===> [appsignal:1.6.4], Bad dependency version for httpoison: ~> 0.11 or ~> 1.0.
===> [batch_loader:0.1.0-beta.3], Bad dependency version for absinthe: ~> 1.4.0 or ~> 1.5.0-beta.
===> [appsignal:1.6.0-alpha.1], Bad dependency version for httpoison: ~> 0.11 or ~> 1.0.
===> Writing index to /home/cecilm/.cache/rebar3/hex/default/packages.idx
===> Package not found in registry: {<<"idna">>,<<"6.0.1">>}.
(Mix) Could not compile dependency :hackney, "/home/cecilm/.mix/rebar3 bare
compile --paths="/home/cecilm/play/Elixir/bug/_build/test/lib/*/ebin"" command
failed. You can recompile this dependency with "mix deps.compile hackney",
update it with "mix deps.update hackney" or clean it with "mix deps.clean
hackney"
Systematics answered 2/6, 2020 at 20:5 Comment(1)
I cannot reproduce it on Elixir 1.10 but search against SO returns many issues with idna. Try to upgrade Elixir to the latest in the first place.Pedestrianize
P
20

This is a compatibility problem with Erlang's rebar package manager and the idna dependency. You need to update rebar in your project by running

mix local.rebar

at the command line. This should fix the problem.

Proportional answered 20/6, 2020 at 23:55 Comment(1)
@TrailingDots here on SO you are obliged to mark the correct answer with a green checkbox. People do help you, please find some time to help future visitors.Pedestrianize
S
7

(from my crosspost on elixirforum.com)

Removing the local rebar3 and mix installations, as well as the currently fetched dependencies and their compiled versions solves this issue.

rm -rf ~/.cache/rebar3 ~/.mix deps _build 
mix deps.get

hex will tell you if new versions are available as far as I remember, the version of rebar installed and used via mix local.rebar is determined by the version of mix (so elixir) you use. It is constrained by an exact version match, not a (semantic) range.

Therefore the good habit is to run mix local.hex when hex tells you it can be updated after a mix deps.get, while you should run mix local.rebar after each update of elixir.

Do this once a week. Some kind of tricky bug relating to dependencies…

Systematics answered 3/6, 2020 at 13:10 Comment(1)
It is usual to accept the answer even when you answered it yourself, so you make it clear to people who find it later that it solved your problem.Gabriella

© 2022 - 2024 — McMap. All rights reserved.