Issue with Ueberauth implementation - “(UndefinedFunctionError) function :unicode_util.lowercase/1 is undefined”

Hi everybody,

I tried to implement Ueberauth from github, but whenever the callback phase should be done, I’m getting an error message. This is how it looks like in the shell (see below). While searching for a solution, I saw others having quite similar issues with this error message which apparently has something to do with hackney? I couldn’t solve the issue however. Thanks for any kind of help.

** (UndefinedFunctionError) function :unicode_util.lowercase/1 is undefined (module :unicode_util is not available)
    :unicode_util.lowercase('github.com')
    (idna) c:/elixir/projekte/discuss/deps/idna/src/idna.erl:57: :idna.lowercase_list/1
    (idna) c:/elixir/projekte/discuss/deps/idna/src/idna.erl:10: :idna.to_ascii/1
    (hackney) c:/elixir/projekte/discuss/deps/hackney/src/hackney_url.erl:96: :hackney_url.normalize/2
    (hackney) c:/elixir/projekte/discuss/deps/hackney/src/hackney.erl:291: :hackney.request/5
    (oauth2) lib/oauth2/request.ex:23: OAuth2.Request.request/6
    (oauth2) lib/oauth2/client.ex:231: OAuth2.Client.get_token/4
    (oauth2) lib/oauth2/client.ex:246: OAuth2.Client.get_token!/4
    (ueberauth_github) lib/ueberauth/strategy/github/oauth.ex:65: Ueberauth.Strategy.Github.OAuth.get_token!/2
    (ueberauth_github) lib/ueberauth/strategy/github.ex:105: Ueberauth.Strategy.Github.handle_callback!/1
    (ueberauth) lib/ueberauth/strategy.ex:299: Ueberauth.Strategy.run_callback/2
    (discuss) web/controllers/auth_controller.ex:1: Discuss.AuthController.phoenix_controller_pipeline/2
    (discuss) lib/discuss/endpoint.ex:1: Discuss.Endpoint.instrument/4
    (discuss) lib/phoenix/router.ex:261: Discuss.Router.dispatch/2
    (discuss) web/router.ex:1: Discuss.Router.do_call/2
    (discuss) lib/discuss/endpoint.ex:1: Discuss.Endpoint.phoenix_pipeline/1
    (discuss) lib/plug/debugger.ex:123: Discuss.Endpoint."call (overridable 3)"/2
    (discuss) lib/discuss/endpoint.ex:1: Discuss.Endpoint.call/2
    (plug) lib/plug/adapters/cowboy/handler.ex:15: Plug.Adapters.Cowboy.Handler.upgrade/4
    (cowboy) c:/elixir/projekte/discuss/deps/cowboy/src/cowboy_protocol.erl:442: :cowboy_protocol.execute/4

Does the fix in this topic Programming Elixir chapter 13 problem solve the problem?

mix deps.update hackney

1 Like

Hi again,

thanks for the reply,
unfortunately it doesn’t - it is resulting in the exact same error message.

There are some commands, or fix (replace httpoison w/ httpoition) at the end of the mentionned post. Maybe one will help You.

But as it seems to be also windows related, for sure I cannot test :slight_smile: as I don’t use it for many years.

1 Like

Try forcing an update to idna and using the latest version, via an override: true if you have to.

1 Like

Thanks,

how can I do that exactly?

Is that inside the deps function in mixs.exs?

Correct, just make sure idna (and probably hackney too) are in your deps at the latest versions and add the override: true (to both).

Sorry, still doesn’t work…

I added

 {:hackney, "== 1.8.6", override: true},
 {:idna, "== 5.0.2", override: true}

to the deps function inside mix.exs.

Then I executed the commands

mix deps.clean --all and
mix deps.get

Then restarting the server and trying the OAuth again - with the same result.

I had this issue on a nerves build, had accidentally compiled a few libraries on OTP20, had to revert back to OTP19 and never cleaned up the deps that had compiled on OTP20.

:unicode_util was added in OTP20, so you may have a version issue with where you are compiling and where you are running your code.

2 Likes

I was actually on OTP19 up until a few hours ago. I had hoped an update to OTP20 might help.

How did you solve the problem btw?

Determining the use of an older version of hackney just made the problem disappear as of now.

I’ve put {:hackney, "== 1.6.5", override: true} into the deps function inside mix.exs

I’m not sure however, if this is a good way of handling the issue or that no other errors will follow subsequently to this.

Running mix deps.clean --all might not be enough. Especially with rebar dependencies there is sometimes some metadata in the download folder remaining.

By actually pinning to an older version, you forced mix to delete the downloaded sources and then download again. Therefore rebars metadata was wiped as well.

If you now get back to current, it should work as well.

If you upgrade your erlang version, it is best do delete deps and run mix deps.get again.

3 Likes

Thanks for your input.

Putting hackney back to version 1.8.6, then

mix deps.clean --all and
mix deps.get

didn’t work.

How am I to implement your suggestion correctly?

Delete the folders deps and _build in your project root.

If that does not work, then there really is a bug that seems to make rebar unable to decide if unicode_util_compat is needed for idna or not.


But I just took a deeper look into the sources of unicode_util_compat. Its quite a bunch of NIFs, and the build instructions for windows are missing. So in fact, downgrading to an older version should help.

There is even y bug report open for a month now: https://github.com/benoitc/unicode_util_compat/issues/2

1 Like

I tried that.

It gives me the same old error. I’ve now gone back to going to the old hackney version 1.6.5.

Since you are on windows, current versions of unicode_util_compat can’t work. So you need to restrict it directly or indirectly to an old version.

All this turning in circles could have been earlier if someone had actually looked at the source and issue tracker of unicode_util_compat.

1 Like