当前位置: 首页 > 工具软件 > Rebar > 使用案例 >

【erlang】rebar3创建、编译报错:badarg

景嘉志
2023-12-01

先上结论,有两种可能:

1. git的user.name使用了中文

通过git config use.name ‘myname’ 改成英文

2. 没有以管理员身份运行命令行工具

详情

在使用rebar3的时候,无论是编译还是创建erlang项目,都会有提示错误,说是有非法的参数

rebar3 new app myapp
......
===> Uncaught error in rebar_core. Run with DEBUG=1 to see stacktrace or consult rebar3.crashdump
===> Uncaught error: badarg

但是查看rebar3.crashdump,发现错误信息只有下边这两行

//rebar3.crashdump
Error: badarg
[]

后边查询资料,发现没有和我相同问题的,判断应该是我这边配置的问题。加上debug=1后执行,发现中间有很多获取本地git的use.name use.email配置的信息,然后我查看这两个配置,发现user.name是中文,怀疑是编码的问题,修改后果然好了。

debug=1 rebar3 new app myapp
===> Expanded command sequence to be run: [{default,new}]
===> Provider: {default,new}
===> Available templates: [{"app",escript,
                                   "rebar/priv/templates/app.template"},
                                  {"cmake",escript,
                                   "rebar/priv/templates/cmake.template"},
                                  {"escript",escript,
                                   "rebar/priv/templates/escript.template"},
                                  {"lib",escript,
                                   "rebar/priv/templates/lib.template"},
                                  {"plugin",escript,
                                   "rebar/priv/templates/plugin.template"},
                                  {"release",escript,
                                   "rebar/priv/templates/release.template"},
                                  {"umbrella",escript,
                                   "rebar/priv/templates/umbrella.template"}]

===> Available templates: [{"app",escript,
                                   "rebar/priv/templates/app.template"},
                                  {"cmake",escript,
                                   "rebar/priv/templates/cmake.template"},
                                  {"escript",escript,
                                   "rebar/priv/templates/escript.template"},
                                  {"lib",escript,
                                   "rebar/priv/templates/lib.template"},
                                  {"plugin",escript,
                                   "rebar/priv/templates/plugin.template"},
                                  {"release",escript,
                                   "rebar/priv/templates/release.template"},
                                  {"umbrella",escript,
                                   "rebar/priv/templates/umbrella.template"}]

===> sh info:
        cwd: "d:/Data/Erlang"
        cmd: git config --global user.name

===>    opts: [return_on_error]

===> Port Cmd: cmd /q /c git config --global user.name
Port Opts: [exit_status,
            {line,16384},
            use_stdio,stderr_to_stdout,hide,eof,binary]
........

===> Executing template file "app.erl"
===> File "myapp/src/myapp_app.erl" already exists
===> Executing template file "sup.erl"
===> File "myapp/src/myapp_sup.erl" already exists
===> Executing template file "otp_app.app.src"
===> File "myapp/src/myapp.app.src" already exists
===> Executing template file "app_rebar.config"
===> File "myapp/rebar.config" already exists
===> Executing template file "gitignore"
===> File "myapp/.gitignore" already exists
===> Executing template file "LICENSE"
===> Uncaught error in rebar_core. Run with DEBUG=1 to see stacktrace or consult rebar3.crashdump
===> Uncaught error: badarg
===> When submitting a bug report, please include the output of `rebar3 report "your command"`
 类似资料: