Mix deps.get: "fatal: Could not read from remote repository."

  defp deps do
    [
      {:httpoison, "~> 1.7.0"},
      {:postgrex, "~> 0.15.5"},
      {:ecto_sql, "~> 3.4.5"},
      {:gen_stage, "~> 1.0.0"},
      {:jason, "~> 1.2.1"},
      {:puid, "~> 1.1", git: "git@github.com:Rio517/Elixir.git"},
      {:parallel_task, "~> 0.1.0"}
    ]
  end
$ ssh-keyscan -t rsa github.com >> ~/.ssh/known_hosts
# github.com:22 SSH-2.0-babeld-383743ad

$ git clone https://github.com/Rio517/Elixir.git
Cloning into 'Elixir'...
remote: Enumerating objects: 29, done.
remote: Counting objects: 100% (29/29), done.
remote: Compressing objects: 100% (18/18), done.
remote: Total 77 (delta 14), reused 20 (delta 11), pack-reused 48
Unpacking objects: 100% (77/77), 46.15 KiB | 1.71 MiB/s, done.


$ mix deps.get
* Updating puid (git@github.com:Rio517/Elixir.git)
git@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
** (Protocol.UndefinedError) protocol String.Chars not implemented for %IO.Stream{device: :standard_io, line_or_bytes: :line, raw: false} of type IO.Stream (a struct)
    (elixir 1.11.2) lib/string/chars.ex:3: String.Chars.impl_for!/1
    (elixir 1.11.2) lib/string/chars.ex:22: String.Chars.to_string/1
    (mix 1.11.2) lib/mix/scm/git.ex:274: Mix.SCM.Git.git!/2
    (mix 1.11.2) lib/mix/scm/git.ex:124: Mix.SCM.Git.checkout/2
    (elixir 1.11.2) lib/file.ex:1552: File.cd!/2
    (mix 1.11.2) lib/mix/dep/fetcher.ex:61: Mix.Dep.Fetcher.do_fetch/3
    (mix 1.11.2) lib/mix/dep/converger.ex:190: Mix.Dep.Converger.all/9
    (mix 1.11.2) lib/mix/dep/converger.ex:201: Mix.Dep.Converger.all/9

Solutions?

SSH setup issue, need to set up a key pair on the build server and upload public key to GitHub

OR

If the dependency is in a public repo, change the reference from SSH URI to HTTPS URI

OR

Change from git: … to github: "user/repo" and let Mix do the right thing

1 Like

Updated mix file as follows:

defp deps do
[ ...
{:puid, "~> 1.1", github: "Rio517/Elixir"},
]
$ mix deps.get
* Updating puid (https://github.com/Rio517/Elixir.git)
remote: Enumerating objects: 29, done.        
remote: Counting objects: 100% (29/29), done.        
remote: Compressing objects: 100% (18/18), done.        
remote: Total 77 (delta 14), reused 20 (delta 11), pack-reused 48        
origin/HEAD set to master
Resolving Hex dependencies...
Dependency resolution completed:
New:
  certifi 2.6.1
  connection 1.1.0
  crypto_rand 1.0.2
  db_connection 2.3.1
  decimal 2.0.0
  ecto 3.4.6
  ecto_sql 3.4.5
  gen_stage 1.0.0
  hackney 1.17.4
  httpoison 1.7.0
  idna 6.1.1
  jason 1.2.2
  metrics 1.0.1
  mimerl 1.2.0
  parallel_task 0.1.1
  parse_trans 3.3.1
  postgrex 0.15.8
  ssl_verify_fun 1.1.6
  telemetry 0.4.2
  unicode_util_compat 0.7.0
* Getting httpoison (Hex package)
* Getting postgrex (Hex package)
* Getting ecto_sql (Hex package)
* Getting gen_stage (Hex package)
* Getting jason (Hex package)
* Getting parallel_task (Hex package)
* Getting crypto_rand (Hex package)
* Getting db_connection (Hex package)
* Getting ecto (Hex package)
* Getting telemetry (Hex package)
* Getting decimal (Hex package)
* Getting connection (Hex package)
* Getting hackney (Hex package)
* Getting certifi (Hex package)
* Getting idna (Hex package)
* Getting metrics (Hex package)
* Getting mimerl (Hex package)
* Getting parse_trans (Hex package)
* Getting ssl_verify_fun (Hex package)
* Getting unicode_util_compat (Hex package)

$ iex -S mix
Erlang/OTP 23 [erts-11.1.7] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:1] [hipe]

===> Compiling parse_trans
==> parallel_task
Compiling 1 file (.ex)
Generated parallel_task app
===> Compiling mimerl
==> connection
Compiling 1 file (.ex)
Generated connection app
===> Compiling metrics
===> Compiling unicode_util_compat
===> Rebar3 detected a lock file from a newer version. It will be loaded in compatibility mode, but important information may be missing or lost. It is recommended to upgrade Rebar3.
===> Compiling idna
==> gen_stage
Compiling 10 files (.ex)
warning: System.stacktrace/0 is deprecated, use __STACKTRACE__ instead
  lib/consumer_supervisor.ex:574

Generated gen_stage app
===> Compiling telemetry
==> decimal
Compiling 4 files (.ex)
Generated decimal app
==> jason
Compiling 8 files (.ex)
Generated jason app
==> ssl_verify_fun
Compiling 7 files (.erl)
Generated ssl_verify_fun app
===> Compiling certifi
===> Rebar3 detected a lock file from a newer version. It will be loaded in compatibility mode, but important information may be missing or lost. It is recommended to upgrade Rebar3.
===> Compiling hackney
==> db_connection
Compiling 14 files (.ex)
Generated db_connection app
==> httpoison
Compiling 3 files (.ex)
Generated httpoison app
==> ecto
Compiling 55 files (.ex)
warning: Decimal.cmp/2 is deprecated. Use compare/2 instead
  lib/ecto/changeset.ex:2149: Ecto.Changeset.validate_number/6

Generated ecto app
==> crypto_rand
Compiling 1 file (.ex)
warning: :crypto.strong_rand_bytes/1 defined in application :crypto is used by the current application but the current application does not directly depend on :crypto. To fix this, you must do one of:

  1. If :crypto is part of Erlang/Elixir, you must include it under :extra_applications inside "def application" in your mix.exs

  2. If :crypto is a dependency, make sure it is listed under "def deps" in your mix.exs

  3. In case you don't want to add a requirement to :crypto, you may optionally skip this warning by adding [xref: [exclude: :crypto]] to your "def project" in mix.exs

Found at 6 locations:
  lib/crypto_rand.ex:60: CryptoRand.random/2
  lib/crypto_rand.ex:112: CryptoRand.shuffle/2
  lib/crypto_rand.ex:164: CryptoRand.take_random/3
  lib/crypto_rand.ex:218: CryptoRand.uniform/2
  lib/crypto_rand.ex:244: CryptoRand.uniform_list/3
  lib/crypto_rand.ex:346: CryptoRand.uniform_bytes/3

Generated crypto_rand app
==> puid
Compiling 3 files (.ex)
Generated puid app
==> postgrex
Compiling 61 files (.ex)
Generated postgrex app
==> ecto_sql
Compiling 26 files (.ex)
Generated ecto_sql app

Since I’m still getting the :crypto.strong_rand_bytes/1 warning it seems that the branch wasn’t installed? Or did I simply misapply your recommendations? :slight_smile:

The lib puid is already be got as you can see

==> puid
Compiling 3 files (.ex)
Generated puid app

The warning is from lib crypto_rand, you can just ignore it, or add the :crypto into the : extra_applications in your mix.exs as it recommended.

That will not change anything, as the top-levels applications :extra_applications is not consifered when resolving “boundaries” for its dependencies.

This warning has to be fixed in the dependency that causes it, though it is safe to ignore it for now and file an issue upstream.

2 Likes

Thanks, you are right.

1 Like