我正在嘗試將此專案用于教育目的:https : //github.com/dronowar/erlang_rest_api
但是代碼編譯和 make run-local 的問題:
erl -config config/sys -pa ./ebin -pa ./deps/*/ebin -sname erl@localhost -s erl -s sync
Erlang/OTP 24 [erts-12.1.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [jit] [dtrace]
{"init terminating in do_boot",{undef,[{erl,start,[],[]},{init,start_em,1,[]},{init,do_boot,3,[]}]}}
init terminating in do_boot ({undef,[{erl,start,[],[]},{init,start_em,1,[]},{init,do_boot,3,[]}]})
Crash dump is being written to: erl_crash.dump...done
make: *** [run-local] Error 1
uj5u.com熱心網友回復:
老實說,這可能是很多事情。該專案已有 3-4 年的歷史,所有的 deps 都未固定,即將獲取最新版本。
可能值得將它們固定在與專案當代相關的事物上。
在 Erlang 24 中,rebar3 由于erlang:get_stacktrace()被洗掉而抱怨,這意味著 deps 沒有被編譯。
我嘗試make使用 Erlang 20運行,但由于缺少 C 編譯器(我在 Windows 上)而最終失敗,但它在構建/編譯程序中確實得到了進一步發展。所以也許降級 Erlang 試試。
uj5u.com熱心網友回復:
似乎 Makefile 與現代 Rebar3 版本不同步。我改變了run-local目標說:
run-local:
erl -config config/sys -pa _build/default/lib/*/ebin -sname $(APPNAME)@localhost -s $(APPNAME) -s sync
(請注意,第二行以制表符開頭,而不是一串空格。)
隨著這一變化,節點為我啟動,并抱怨無法連接到 Postgres。
那你怎么會知道呢?你得到的錯誤是{undef,[{erl,start,[],[]}。這意味著它試圖用零引數呼叫start模塊中的erl函式(引數串列為空,[]),但沒有這樣的函式,要么是因為模塊沒有這樣的函式,要么是因為整個模塊都不能'不加載。
所以我搜索了編譯模塊,erl.beam:
$ find . -name erl.beam
./_build/default/lib/erl/ebin/erl.beam
這幾天Rebar3喜歡把編譯好的檔案放到_build子目錄下,但是在寫erlang_rest_api的時候,它顯然只是使用了ebin子目錄。-paerl的引數指示模塊搜索路徑,所以讓我們在那里添加正確的目錄,并洗掉-pa ./ebin -pa ./deps/*/ebin現在未使用的目錄。
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/337385.html
