Mix deps.get error - (FunctionClauseError) no function clause matching in String.to_charlist/1

➜  magic git:(master) mix deps.get

19:29:12.008 [error] Task #PID<0.189.0> started from :hex_fetcher terminating
** (FunctionClauseError) no function clause matching in String.to_charlist/1
    (elixir) lib/string.ex:2029: String.to_charlist(nil)
    (hex) lib/hex/http/ssl.ex:56: Hex.HTTP.SSL.ssl_opts/1
    (hex) lib/hex/http.ex:34: Hex.HTTP.build_http_opts/2
    (hex) lib/hex/http.ex:9: Hex.HTTP.request/5
    (hex) lib/hex/registry/server.ex:320: anonymous fn/3 in Hex.Registry.Server.prefetch_online/2
    (elixir) lib/task/supervised.ex:88: Task.Supervised.do_apply/2
    (elixir) lib/task/supervised.ex:38: Task.Supervised.reply/5
    (stdlib) proc_lib.erl:247: :proc_lib.init_p_do_apply/3
Function: #Function<16.115348921/0 in Hex.Registry.Server.prefetch_online/2>
    Args: []
** (exit) exited in: GenServer.call(Hex.Registry.Server, {:versions, "hexpm", "poolboy"}, 60000)
    ** (EXIT) time out
    (elixir) lib/gen_server.ex:834: GenServer.call/3
    (hex) lib/hex/registry/server.ex:56: Hex.Registry.Server.versions/2
    (hex) lib/hex/remote_converger.ex:419: Hex.RemoteConverger.verify_dep/3
    (elixir) lib/enum.ex:743: anonymous fn/3 in Enum.each/2
    (stdlib) lists.erl:1263: :lists.foldl/3
    (elixir) lib/enum.ex:1915: Enum.each/2
    (hex) lib/hex/remote_converger.ex:40: Hex.RemoteConverger.converge/2
    (mix) lib/mix/dep/converger.ex:95: Mix.Dep.Converger.all/4

Elixir version is

Erlang/OTP 20 [erts-9.3] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:10] [hipe] [kernel-poll:false] [dtrace]

Elixir 1.6.4 (compiled with OTP 20)

Hex version is

Hex v0.18.1

And this is what I have down in iTerm2 use history

10181  gst
10182  docker build -t registry-hlj.helijia.com/gitlab_lego_elixir --build-arg mix_env=dev --build-arg branch=to-sky! .
10183  gst
10184  gd
10185  gst
10186  gco .
10187  gst
10188  docker build -t registry-hlj.helijia.com/gitlab_lego_elixir --build-arg mix_env=dev --build-arg branch=to-sky! .
10189  tig
10190  registry-hlj.helijia.com/gitlab_lego_elixir
10191  ssh registry-hlj.helijia.com
10192  docker build -t registry-hlj.helijia.com/gitlab_lego_elixir --build-arg mix_env=dev --build-arg branch=to-sky! .
10193  mix hex.organization key acme
10194  mix hex.organization key helijia
10195  mix hex.organization list
10196  mix hex.organization key helijia list
10197  mix hex.organization key helijia generate
10198  docker build -t registry-hlj.helijia.com/gitlab_lego_elixir --build-arg mix_env=dev --build-arg branch=to-sky! .
10199  mix deps.get

I don’t know what going on… and have no idea how and why it happen?
Someone know it?
Thanks.

Can you show your Dockerfile? It is possible you have to force rebuild your Docker image so that it fetches the latest Hex version, if you add mix hex.info to the Dockerfile you can verify that it uses the latest Hex version 0.18.1.

Yes, thanks for help. I can’t edit my question (first time use this). Here’s my DockerFile.

FROM         registry-hlj.helijia.com/hlj-elixir:1.6.4
MAINTAINER   skylab <skylab@helijia.com>

ARG branch
ARG mix_env

WORKDIR /home
RUN git clone -b $branch ssh://git@git.hlj.team:10/web/magic.git

WORKDIR /home/magic
RUN git rev-parse HEAD
RUN HEX_MIRROR=https://hexpm.upyun.com mix do local.hex --force, local.rebar --force
RUN mix hex.config mirror_url https://hexpm.upyun.com
RUN mix hex.organization auth helijia --key xxxxxxxxxxxxxxxxxxxxx
RUN mix deps.get && yarn install && yarn dist
RUN MIX_ENV=${mix_env} mix phx.digest
RUN MIX_ENV=${mix_env} mix release —env=${mix_env}
RUN mv _build/${mix_env}/rel/magic/ /app
# RUN rm -rf /home/magic/

WORKDIR /app
ENTRYPOINT /app/bin/magic start && tail -F /app/var/log/run_erl.log

Please verify that you are using the latest hex version with mix hex.info. I see that you are using a mirror when installing hex, maybe it is slow to refresh?

Yes, I’m sure I use the latest version. Before this error I just update hex with mix hex.local.
Then the version is

Hex:    0.18.1
Elixir: 1.6.5
OTP:    20.3.6

just a wild guess, is this output from inside docker container or your local computer? Because your docker file says FROM registry-hlj.helijia.com/hlj-elixir:1.6.4, but above is 1.6.5

1 Like

There is something may help.
I got this error in the branch with Dockerfile, Then check out to master branch deps.get still got error.
But when I change to another phoenix project, deps.get works.

I back home, use another computer (also use latest hex) , no error. This computed has no access to registry-hlj.helijia.com so I can’t try build docker.

And I try rm -rf the project then clone it again. Not work.

From my local computer, since the error is on local computer.

:pray:
The trace.txt file after elixir -e ":inets_trace.enable(:max, 'trace.txt', :httpc)" -S mix deps.get

It is possible that you use a version manager such as asdf? If that’s the case it could switch between Elixir versions and you would get another installed Hex version. This might be the case because the output you have shown shows different Elixir versions (1.6.4 and 1.6.5). Run mix local.hex again in the project where you see the crash to ensure you have the latest Hex version installed for the Elixir version your project uses.

Very sorry for misleading.
I’m not use asdf or other version manager. 1.6.4 elixir is my MBP from company and 1.6.5 is home MBP.
Sorry…
Now I’m sure I use the 0.18.1 version of hex.
Is there some setting (httpc or other) bind up with project not branch or computer? Because as I mentioned before: same computer same environment phoenix project one deps.get work another can’t. And in the error project, I checkout branch to master it still error. I think this will be the only entry point I fix this.

After I compare two mix.exs file from difference project finally find out
{:sso_login, ">= 0.0.0", organization: "helijia"} the organization deps is the key.
When I remove it, no error!!
So the reason are in those commands in the iTerm2 history

mix hex.organization key acme
mix hex.organization key helijia
mix hex.organization list
mix hex.organization key helijia list
mix hex.organization key helijia generate

And after I deauth mix hex.user deauth and mix hex.user auth it works!!!
Still don’t know why this cause error but fix it…
Thanks guys!