smk*_*ber 1 elixir bcrypt phoenix-framework
首先,我在Windows 10中开发.我vcvarsall.bat amd64
在每次编译之前运行.我在用:
Elixir 1.4.2
凤凰城v1.2.1
我开始了一个全新的项目,制作了一个用户表,一切都运行良好.我添加了comeonin哈希pw,我不能再创建用户.我得到一个错误页面说:
function Comeonin.Bcrypt.hashpwsalt/1 is undefined (module Comeonin.Bcrypt is not available)
以下是相关文件的代码:
Mix.exs
# mix.exs
...
def application do
[mod: {PollarAppV2, []},
applications: [:phoenix, :phoenix_pubsub, :phoenix_html, :cowboy, :logger, :gettext,
:phoenix_ecto, :postgrex, :comeonin, :timex]]
end
...
defp deps do
[{:phoenix, "~> 1.2.1"},
{:phoenix_pubsub, "~> 1.0"},
{:phoenix_ecto, "~> 3.0"},
{:postgrex, ">= 0.0.0"},
{:phoenix_html, "~> 2.6"},
{:phoenix_live_reload, "~> 1.0", only: :dev},
{:gettext, "~> 0.11"},
{:cowboy, "~> 1.0"},
{:comeonin, "~> 3.0"},
{:timex, "~> 3.0"}]
end
...
Run Code Online (Sandbox Code Playgroud)
User.ex
# user.ex
...
defp generate_password_hash(changeset) do
case changeset do
%Ecto.Changeset{valid?: true, changes: %{password: password}} ->
put_change(changeset, :encrypted_password, Comeonin.Bcrypt.hashpwsalt(password))
_ ->
changeset
end
end
Run Code Online (Sandbox Code Playgroud)
当我尝试保存调用generate_password_hash的用户时,我收到此错误:
安慰
[warn] The on_load function for module Elixir.Comeonin.Bcrypt returned { :error,
{:load_failed,
'Failed to load NIF library c:/code/phoenix/pollar_app_v2/_build/dev/lib/comeonin/priv/bcrypt_nif: \'Unspecified error\''}}
[info] Sent 500 in 16ms
[error] #PID<0.430.0> running PollarAppV2.Endpoint terminated
Server: localhost:4000 (http)
Request: POST /users
** (exit) an exception was raised:
** (UndefinedFunctionError) function Comeonin.Bcrypt.hashpwsalt/1 is
undefined (module Comeonin.Bcrypt is not available)
(comeonin) Comeonin.Bcrypt.hashpwsalt("asdfasdf")
(pollar_app_v2) web/models/user.ex:40: PollarAppV2.User.generate_password_hash/1
(pollar_app_v2) web/controllers/user_controller.ex:17: PollarAppV2.UserController.create/2
(pollar_app_v2) web/controllers/user_controller.ex:1: PollarAppV2.UserController.action/2
(pollar_app_v2) web/controllers/user_controller.ex:1: PollarAppV2.UserController.phoenix_controller_pipeline/2
(pollar_app_v2) lib/pollar_app_v2/endpoint.ex:1: PollarAppV2.Endpoint.instrument/4
(pollar_app_v2) lib/phoenix/router.ex:261: PollarAppV2.Router.dispatch/2
(pollar_app_v2) web/router.ex:1: PollarAppV2.Router.do_call/2
(pollar_app_v2) lib/pollar_app_v2/endpoint.ex:1: PollarAppV2.Endpoint.phoenix_pipeline/1
(pollar_app_v2) lib/plug/debugger.ex:123: PollarAppV2.Endpoint."call
(overridable 3)"/2
(pollar_app_v2) lib/pollar_app_v2/endpoint.ex:1: PollarAppV2.Endpoint.call/2
(plug) lib/plug/adapters/cowboy/handler.ex:15: Plug.Adapters.Cowboy.Handler.upgrade/4
(cowboy)
c:/code/phoenix/pollar_app_v2/deps/cowboy/src/cowboy_protocol.erl:442: :cowboy_protocol.execute/4
Run Code Online (Sandbox Code Playgroud)
我已经运行mix deps.clean --all
,mix deps.update --all
,mix deps.compile
,mix compile
,都多次等等.它永远不会指示nif文件没有编译,我可以在文件结构中看到正确位置的文件,但我无法访问应用程序中的Bcrypt.关于如何解决这个问题的任何想法?
归档时间: |
|
查看次数: |
1206 次 |
最近记录: |