我正在使用一个名为erlang_decimal的 erlang 库来做一些十进制数学运算。我的应用程序还使用Decimal作为 Ecto 的子依赖项,Ecto 是基本相同类型的 Elixir 库。
这是我的mix.exs
:
defp deps do
[
{:bcrypt_elixir, "~> 1.0"},
{:comeonin, "~> 4.0"},
{:configparser_ex, "~> 2.0"},
{:csv, "~> 2.1.1"},
{:decimal, "~> 1.0},
{:ecto_enum, "~> 1.0"},
{:ecto_sql, "~> 3.0"},
{:erlang_decimal, "~> 0.4", app: false},
{:ex_aws, "~> 2.0"},
{:ex_aws_s3, "~> 2.0"},
{:ex_machina, "~> 2.2", only: [:dev, :test]},
{:ex_twilio, "~> 0.6.0"},
{:gettext, "~> 0.11"},
{:httpoison, "~> 1.0"},
{:jason, "~> 1.0"},
{:phoenix, "~> 1.4.0"},
{:phoenix_ecto, "~> 4.0"},
{:phoenix_html, "~> 2.10"},
{:phoenix_live_reload, "~> 1.0", only: :dev},
{:phoenix_pubsub, "~> 1.0"},
{:plug, "~> 1.7"},
{:plug_cowboy, "~> 2.0"},
{:postgrex, ">= 0.0.0"},
{:ranch, "~> 1.3"},
{:sentry, "~> 7.0"},
{:signed_overpunch, "~> 0.2"},
{:sweet_xml, "~> 0.6"},
{:telcom_parser, in_umbrella: true},
{:timex, github: "bitwalker/timex", ref: "74afe810ee9c8e58e057830e62a865230ce00133"},
{:trixie, in_umbrella: true}
]
end
部署更改后,我遇到了以下异常:
Elixir.UndefinedFunctionError: function Decimal.new/3 is undefined (module Decimal is not available)
Module "Elixir.Decimal", in Decimal.new/3
File "lib/postgrex/type_module.ex", line 713, in Postgrex.DefaultTypes."Elixir.Postgrex.Extensions.Numeric"/6
File "lib/postgrex/protocol.ex", line 2733, in Postgrex.Protocol.rows_recv/4
File "lib/postgrex/protocol.ex", line 1777, in Postgrex.Protocol.recv_execute/5
File "lib/postgrex/protocol.ex", line 1652, in Postgrex.Protocol.bind_execute/4
File "lib/db_connection/holder.ex", line 268, in DBConnection.Holder.holder_apply/4
File "lib/db_connection.ex", line 1189, in DBConnection.run_execute/5
File "lib/db_connection.ex", line 1276, in DBConnection.run/6
Module "erlang", in :erlang.apply/2
是否存在某种命名空间冲突?
编辑:
Dialyzer 能够解决这个问题:
Total errors: 6, Skipped: 0
done in 0m5.83s
:0:unknown_function
Function Decimal.compare/2 does not exist.
________________________________________________________________________________
:0:unknown_function
Function Decimal.div/2 does not exist.
________________________________________________________________________________
:0:unknown_function
Function Decimal.mult/2 does not exist.
________________________________________________________________________________
:0:unknown_function
Function Decimal.new/1 does not exist.
________________________________________________________________________________
:0:unknown_function
Function Decimal.round/3 does not exist.
________________________________________________________________________________
:0:unknown_function
Function Decimal.to_integer/1 does not exist.
________________________________________________________________________________
done (warnings were emitted)
我更新了mix.exs
包括{:decimal, "~> 1.0"}