我正在使用Erlang语言的vscode插件。我创建了一个新的rebar3应用程序,并创建了一个简单的应用程序,不使用监督:
-module(test_app_app).
-behaviour(application).
-export([start/2, stop/1]).
start(_StartType, _StartArgs) ->
load_file("input.txt").
stop(_State) ->
ok.
load_file(Filename) ->
case file:read_file(Filename) of
{ok, Bin} ->
Bin;
{error, Reason} ->
erlang:error(Reason)
end.
我配置了一个launch.json文件,如下所示:
{
"version": "0.2.0",
"configurations": [
{
"name": "Launch erlang",
"type": "erlang",
"request": "launch",
"cwd": "${workspaceRoot}",
"arguments": "-s test_app_app start",
"preLaunchTask": "rebar3 compile"
}
]
}
和用于编译的tasks.json:
{
"version": "2.0.0",
"tasks": [
{
"label": "rebar3 compile",
"type": "shell",
"command": "rebar3 compile",
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher": "$erlang"
}
]
}
当我按F5键时,得到以下输出:
compiling erlang bridge to '/home/peter/.vscode/extensions/pgourlain.erlang-0.8.1/_build/default/lib/ebin'
Compiling arguments file "/tmp/bp_1454870.erl"
Compile result: sucess
Module bp_1454870 loaded
{"init terminating in do_boot",{undef,[{t
est_app_app,start,[],[]},{init,start_em,1,[]},{init,do_boot,3,[]}]}}
init terminating in do_boot ({undef,[{test_app_app,start,[],[]},{init,start_em,1,[]},{init,do_boot,3,[]}]})
Crash dump is being written to: erl_crash.dump...
done
erl exit code:1
erl exit with code 1
有人知道为什么这对我不起作用吗?
1条答案
按热度按时间qaxu7uf21#
问题出在您的launch.json中。您尝试运行模块
test_app_app
中的函数start/0
,但该函数不存在。尝试使用