Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fails to compile if optional plug dependency is missin #644

Closed
aeons opened this issue Jan 31, 2020 · 7 comments · Fixed by #663
Closed

Fails to compile if optional plug dependency is missin #644

aeons opened this issue Jan 31, 2020 · 7 comments · Fixed by #663
Labels

Comments

@aeons
Copy link

aeons commented Jan 31, 2020

I am not sure whether this is an issue for Guardian or for Elixir/mix, but here goes.

If you create an empty project and add {:guardian, "~> 2.0"} as a dependency, compilation fails with

𝝺 mix
==> jose
Compiling 105 files (.erl)
Compiling 8 files (.ex)
warning: Poison.EncodeError.exception/1 is undefined (module Poison.EncodeError is not available or is yet to be defined)
  lib/jose/poison/lexical_encoder.ex:8: JOSE.Poison.LexicalEncodeError.exception/1

Generated jose app
==> guardian
Compiling 24 files (.ex)

== Compilation error in file lib/guardian/plug/pipeline.ex ==
** (CompileError) lib/guardian/plug/pipeline.ex:109: module Plug.Conn is not loaded and could not be found
    (stdlib 3.11.1) lists.erl:1354: :lists.mapfoldl/3
    (stdlib 3.11.1) lists.erl:1355: :lists.mapfoldl/3
    (elixir 1.10.0) expanding macro: Kernel.if/2
could not compile dependency :guardian, "mix compile" failed. You can recompile this dependency with "mix deps.compile guardian", update it with "mix deps.update guardian" or clean it with "mix deps.clean guardian"

The referenced line is here

if Code.ensure_loaded?(Plug) do
import Plug.Conn

@doomspork
Copy link
Member

@aeons what version of Elixir are you on?

@ueberauth/developers have any of you seen this before? I don't think I've ever used Guardian without Plug. I can try to spin up an empty project to test.

@aeons
Copy link
Author

aeons commented Mar 11, 2020

Elixir 1.10.

I was trying to get sans_password updated to the newest guardian, and that does not have a dependency on anything except guardian.

@Hanspagh
Copy link
Contributor

This is indeed a problem

== Compilation error in file lib/guardian/plug/pipeline.ex ==
** (CompileError) lib/guardian/plug/pipeline.ex:109: module Plug.Conn is not loaded and could not be found
    (stdlib) lists.erl:1354: :lists.mapfoldl/3
    (stdlib) lists.erl:1355: :lists.mapfoldl/3
    (elixir) expanding macro: Kernel.if/2

This part is wrapped in Code.ensure_loaded, but I guess it is a problem simular to this
elixir-lang/elixir#8970

Do we want to go that direction or should we just include plug as a dependency?

@Hanspagh
Copy link
Contributor

@ueberauth/developers ?

@wevnasc
Copy link

wevnasc commented Aug 3, 2020

I am having the same issue, I just added the plug as a dependency and solved, but I didn't want to add the plug without to use it, is there another way to solve it?

@ramaboo
Copy link

ramaboo commented Aug 7, 2020

I am seeing this as well :(
Screen Shot 2020-08-06 at 18 12 11

@Hanspagh
Copy link
Contributor

Hanspagh commented Oct 3, 2020

Fixed by #663

@Hanspagh Hanspagh closed this as completed Oct 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants