2015-12-21 45 views
14

我在編程Phoenix書籍中,正在執行該部分以實現登錄/登出經過身份驗證的用戶,並且收到錯誤我不知道該如何處理:Phoenix error:模塊未加載/不可用

mix phoenix.server 
Compiled lib/rumbl.ex 
Compiled lib/rumbl/repo.ex 
Compiled web/channels/user_socket.ex 
Compiled web/web.ex 
Compiled web/models/user.ex 

== Compilation error on file web/router.ex == 
** (UndefinedFunctionError) undefined function: Rumbl.Auth.init/1 (module Rumbl.Auth is not available) 
    Rumbl.Auth.init([repo: Rumbl.Repo]) 
    (plug) lib/plug/builder.ex:198: Plug.Builder.init_module_plug/3 
    (plug) lib/plug/builder.ex:186: anonymous fn/4 in Plug.Builder.compile/3 
    (elixir) lib/enum.ex:1387: Enum."-reduce/3-lists^foldl/2-0-"/3 
    (plug) lib/plug/builder.ex:186: Plug.Builder.compile/3 
    web/router.ex:4: (module) 
    (stdlib) erl_eval.erl:669: :erl_eval.do_apply/6 
    (elixir) lib/kernel/parallel_compiler.ex:100: anonymous fn/4 in Kernel.ParallelCompiler.spawn_compilers/8 


== Compilation error on file lib/rumbl/endpoint.ex == 
** (UndefinedFunctionError) undefined function: Rumbl.Router.init/1 (module Rumbl.Router is not available) 
    Rumbl.Router.init([]) 
    (plug) lib/plug/builder.ex:198: Plug.Builder.init_module_plug/3 
    (plug) lib/plug/builder.ex:186: anonymous fn/4 in Plug.Builder.compile/3 
    (elixir) lib/enum.ex:1387: Enum."-reduce/3-lists^foldl/2-0-"/3 
    (plug) lib/plug/builder.ex:186: Plug.Builder.compile/3 
    (phoenix) expanding macro: Phoenix.Endpoint.__before_compile__/1 
    lib/rumbl/endpoint.ex:1: Rumbl.Endpoint (module) 
    (elixir) lib/kernel/parallel_compiler.ex:100: anonymous fn/4 in Kernel.ParallelCompiler.spawn_compilers/8 


== Compilation error on file web/views/user_view.ex == 
** (CompileError) web/views/user_view.ex:2: module Rumbl.Router.Helpers is not loaded and could not be found 
    expanding macro: Rumbl.Web.__using__/1 
    web/views/user_view.ex:2: Rumbl.UserView (module) 
    (elixir) expanding macro: Kernel.use/2 
    web/views/user_view.ex:2: Rumbl.UserView (module) 
    (elixir) lib/kernel/parallel_compiler.ex:100: anonymous fn/4 in Kernel.ParallelCompiler.spawn_compilers/8 


== Compilation error on file web/views/error_view.ex == 
** (CompileError) web/views/error_view.ex:2: module Rumbl.Router.Helpers is not loaded and could not be found 
    expanding macro: Rumbl.Web.__using__/1 
    web/views/error_view.ex:2: Rumbl.ErrorView (module) 
    (elixir) expanding macro: Kernel.use/2 
    web/views/error_view.ex:2: Rumbl.ErrorView (module) 
    (elixir) lib/kernel/parallel_compiler.ex:100: anonymous fn/4 in Kernel.ParallelCompiler.spawn_compilers/8 


== Compilation error on file web/controllers/auth.ex == 
** (CompileError) web/controllers/auth.ex:3: module Comeonin.Bcypt is not loaded and could not be found 
    (stdlib) erl_eval.erl:669: :erl_eval.do_apply/6 
    (elixir) lib/kernel/parallel_compiler.ex:100: anonymous fn/4 in Kernel.ParallelCompiler.spawn_compilers/8 


== Compilation error on file web/controllers/user_controller.ex == 
** (CompileError) web/controllers/user_controller.ex:2: module Rumbl.Router.Helpers is not loaded and could not be found 
    expanding macro: Rumbl.Web.__using__/1 
    web/controllers/user_controller.ex:2: Rumbl.UserController (module) 
    (elixir) expanding macro: Kernel.use/2 
    web/controllers/user_controller.ex:2: Rumbl.UserController (module) 
    (elixir) lib/kernel/parallel_compiler.ex:100: anonymous fn/4 in Kernel.ParallelCompiler.spawn_compilers/8 


== Compilation error on file web/controllers/page_controller.ex == 
** (CompileError) web/controllers/page_controller.ex:2: module Rumbl.Router.Helpers is not loaded and could not be found 
    expanding macro: Rumbl.Web.__using__/1 
    web/controllers/page_controller.ex:2: Rumbl.PageController (module) 
    (elixir) expanding macro: Kernel.use/2 
    web/controllers/page_controller.ex:2: Rumbl.PageController (module) 
    (elixir) lib/kernel/parallel_compiler.ex:100: anonymous fn/4 in Kernel.ParallelCompiler.spawn_compilers/8 


== Compilation error on file web/views/session_view.ex == 
** (CompileError) web/views/session_view.ex:2: module Rumbl.Router.Helpers is not loaded and could not be found 
    expanding macro: Rumbl.Web.__using__/1 
    web/views/session_view.ex:2: Rumbl.SessionView (module) 
    (elixir) expanding macro: Kernel.use/2 
    web/views/session_view.ex:2: Rumbl.SessionView (module) 
    (elixir) lib/kernel/parallel_compiler.ex:100: anonymous fn/4 in Kernel.ParallelCompiler.spawn_compilers/8 


== Compilation error on file web/views/page_view.ex == 
** (CompileError) web/views/page_view.ex:2: module Rumbl.Router.Helpers is not loaded and could not be found 
    expanding macro: Rumbl.Web.__using__/1 
    web/views/page_view.ex:2: Rumbl.PageView (module) 
    (elixir) expanding macro: Kernel.use/2 
    web/views/page_view.ex:2: Rumbl.PageView (module) 
    (elixir) lib/kernel/parallel_compiler.ex:100: anonymous fn/4 in Kernel.ParallelCompiler.spawn_compilers/8 


== Compilation error on file web/views/layout_view.ex == 
** (CompileError) web/views/layout_view.ex:2: module Rumbl.Router.Helpers is not loaded and could not be found 
    expanding macro: Rumbl.Web.__using__/1 
    web/views/layout_view.ex:2: Rumbl.LayoutView (module) 
    (elixir) expanding macro: Kernel.use/2 
    web/views/layout_view.ex:2: Rumbl.LayoutView (module) 
    (elixir) lib/kernel/parallel_compiler.ex:100: anonymous fn/4 in Kernel.ParallelCompiler.spawn_compilers/8 


== Compilation error on file web/controllers/session_controller.ex == 
** (CompileError) web/controllers/session_controller.ex:2: module Rumbl.Router.Helpers is not loaded and could not be found 
    expanding macro: Rumbl.Web.__using__/1 
    web/controllers/session_controller.ex:2: Rumbl.SessionController (module) 
    (elixir) expanding macro: Kernel.use/2 
    web/controllers/session_controller.ex:2: Rumbl.SessionController (module) 
    (elixir) lib/kernel/parallel_compiler.ex:100: anonymous fn/4 in Kernel.ParallelCompiler.spawn_compilers/8 

我檢查和雙重檢查我的代碼對書,但看不到任何東西。
我對項目文件的位置:https://github.com/bordeltabernacle/learning-phoenix/tree/master/rumbl

至於我可以告訴Rumbl.Auth.init功能是有在auth.ex控制器文件,我不知道是什麼Rumbl.Router.Helpers文件或如何加載它。當我刪除router.ex文件中唯一的新行時,由於該應用程序正在工作,我得到相同的錯誤。
恐怕我還沒有足夠的知識來解決這個問題。

回答

8

你有錯字在https://github.com/bordeltabernacle/learning-phoenix/blob/master/rumbl/web/controllers/auth.ex

import Comeonin.Bcypt, only: [checkpw: 2] 

應該是

import Comeonin.Bcrypt, only: [checkpw: 2] 
13

我想你應該嘗試清理DEPS,然後獲取和重新編譯之前達到斷絕

所以儘量

mix deps.clean --all 
mix deps.get 
mix deps.compile 
mix phoenix.server 

好運

+2

做'mix deps.compile'幫助我的視圖模塊不再被檢測到。 – Vantalk

1

你也可以刪除_build目錄,並與mix phoenix.server(鳳凰城1.2)或mix phx.server(鳳凰城1.3)重新啓動服務器。

這樣做將首次從頭開始提取所有依賴關係。我更喜歡這種方法,因爲我不需要輸入一堆命令,我只需要刪除一個目錄並重新運行我的終端上的最新命令即mix phx.server。是的,我很懶。

祝你好運。