Heroku上的Elixir应用程序**(ErlangError)erlang错误::“函数未导出”

时间:2016-01-06 14:24:43

标签: heroku elixir phoenix-framework

我遇到了部署在heroku上的凤凰应用程序的问题。当我在本地运行此代码时,一切正常,没有错误。部署到heroku时,应用程序成功部署并启动,但在使用应用程序时,GenServer进程崩溃时出现此错误:

[error] GenServer :main_worker terminating
** (exit) an exception was raised:
   ** (ErlangError) erlang error: :"function not exported"
       (elixir) Map.get_and_update!(%{"location" => %{"latitude" => 35.9628632, "longitude" => -86.8216522}, "name" => "Dover", "pickups" => 0}, "pickups", #Function<0.62518121/1 in BusTracker.MainWorker.handle_call/3>)
       (bus_tracker) lib/bus_tracker/main_worker.ex:27: BusTracker.MainWorker.handle_call/3
       (stdlib) gen_server.erl:629: :gen_server.try_handle_call/4
       (stdlib) gen_server.erl:661: :gen_server.handle_msg/5
       (stdlib) proc_lib.erl:240: :proc_lib.init_p_do_apply/3
13:25:03.112 [error] GenServer #PID<0.319.0> terminating
** (exit) an exception was raised:
   ** (ErlangError) erlang error: {{:undef, [{Map, :get_and_update!, [%{"location" => %{"latitude" => 35.9628632, "longitude" => -86.8216522}, "name" => "Dover", "pickups" => 0}, "pickups", #Function<0.62518121/1 in BusTracker.MainWorker.handle_call/3>], []}, {BusTracker.MainWorker, :handle_call, 3, [file: 'lib/bus_tracker/main_worker.ex', line: 27]}, {:gen_server, :try_handle_call, 4, [file: 'gen_server.erl', line: 629]}, {:gen_server, :handle_msg, 5, [file: 'gen_server.erl', line: 661]}, {:proc_lib, :init_p_do_apply, 3, [file: 'proc_lib.erl', line: 240]}]}, {GenServer, :call, [:main_worker, {:update_pickups, {"Dover", 1}}, 5000]}}
       (elixir) lib/gen_server.ex:356: GenServer.call/3
       (bus_tracker) web/channels/main_channel.ex:38: BusTracker.MainChannel.handle_in/3
       (phoenix) lib/phoenix/channel/server.ex:210: Phoenix.Channel.Server.handle_info/2
       (stdlib) gen_server.erl:615: :gen_server.try_dispatch/4
       (stdlib) gen_server.erl:681: :gen_server.handle_msg/5
       (stdlib) proc_lib.erl:240: :proc_lib.init_p_do_apply/3

以下是错误引用的代码。

   defmodule BusTracker.MainWorker do
     use GenServer
     # . . .

     # Server
25>  def handle_call({:update_pickups, {name,num}}, _, state) do
26>    waypoint = state.waypoints[name]
27>    {_, new_waypoint}  = Map.get_and_update! waypoint, "pickups",   fn(val) -> {"pickups", val + num} end
28>    {_, new_waypoints} = Map.get_and_update! state.waypoints, name, fn(val) -> {name, new_waypoint} end
29>    {_, new_state}     = Map.get_and_update! state, :waypoints ,    fn(val) -> {:waypoints, new_waypoints} end
30>    {:reply, new_waypoint["pickups"], new_state}
31>  end
     # . . . 
  end

我正在使用这些heroku构建包:

  • github.com/HashNuke/heroku-buildpack-elixir.git
  • github.com/gjaldon/heroku-buildpack-phoenix-static.git

这是我的elixir_buildpack.config:

# Erlang version
erlang_version=18.1.3

# Elixir version
elixir_version=1.0.4

# Always rebuild from scratch on every deploy?
always_rebuild=false

# Export heroku config vars
# config_vars_to_export=(DATABASE_URL)

# A command to run right after compiling the app
post_compile="pwd"

Aug 5th, 2015上的elixir irc频道中提到了这一点,但我无法通过讨论弄清楚如何解决问题。我是一个长生不老药/二郎新手,所以有人可以给我一些帮助吗?感谢

1 个答案:

答案 0 :(得分:2)

确保您在开发环境中使用的Heroku上使用相同版本的Elixir和Erlang。

# Erlang version
erlang_version=18.1.3

# Elixir version
elixir_version=1.1.1