Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/elixir/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/security/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Elixir 文件web/controllers/auth_controller.ex undefined function plug/1上的编译错误 神秘的错误消息_Elixir_Phoenix Framework_Ueberauth - Fatal编程技术网

Elixir 文件web/controllers/auth_controller.ex undefined function plug/1上的编译错误 神秘的错误消息

Elixir 文件web/controllers/auth_controller.ex undefined function plug/1上的编译错误 神秘的错误消息,elixir,phoenix-framework,ueberauth,Elixir,Phoenix Framework,Ueberauth,在尝试为我们的项目实现ueberauth时,我们看到了一条以前从未见过的错误消息。(注意,这并非特定于ueberauth此错误将出现在任何未包含控制器“助手”的控制器中) 确切的错误消息是: == Compilation error on file web/controllers/auth_controller.ex == ** (CompileError) web/controllers/auth_controller.ex:4: undefined function plug/1 (

在尝试为我们的项目实现
ueberauth
时,我们看到了一条以前从未见过的错误消息。(注意,这并非特定于
ueberauth
此错误将出现在任何未包含控制器“助手”的控制器中)

确切的错误消息是:

== Compilation error on file web/controllers/auth_controller.ex ==
** (CompileError) web/controllers/auth_controller.ex:4: undefined function plug/1
    (stdlib) erl_eval.erl:670: :erl_eval.do_apply/6
    (elixir) lib/kernel/parallel_compiler.ex:117: anonymous fn/4 in Kernel.ParallelCompiler.spawn_compilers/1
代码快照:

答复: 忘记在我们的控制器文件中包含
:controller
助手

use Auth.Web, :controller
感谢Sam Houston查看代码并发现如何修复它。


案例中发布此问题+答案
某人
其他人
在他们的Phoenix项目中看到此错误消息,在谷歌搜索时找不到答案

将答案分享给其他人解释

use Auth.Web, :controller

分享答案,让其他人来解释

use Auth.Web, :controller

plug
宏是在plug.Builder中定义的,您可以在使用前将其导入:

use Plug.Builder

plug :any_plug_you_like

对于Phoenix,它在
Phoenix.Controller.Pipeline
中定义,注入到
Phoenix.Controller
中,再次通过
使用Auth.Web注入,:Controller

在plug.Builder中定义
plug
宏,您可以在使用前导入它:

use Plug.Builder

plug :any_plug_you_like

对于Phoenix,它在
Phoenix.Controller.Pipeline
中定义,注入到
Phoenix.Controller
中,再次通过
使用Auth.Web,:Controller
将答案作为答案发布⇓ 请:)将答案作为答案发布⇓ 请:)