Hello, all.
Could you help me, please?
The question is that
After the user-defined behavior is implemented, the server outputs, for example
3 -behavior(gen_example). % W: behavior gen_example undefined
An example from here: Implement a new Erlang OTP behavior
Findings:
- Cowboy behaviour undefined #1044
Workaround from here: Add the following to the local erlang_ls.config file (see https://erlang-ls.github.io/configuration/)
This workaround doesnβt work for me.code_path_extra_dirs: - "./_build/default/lib/*/ebin/"
β― grep -HRs "\-behavior" . ./test/handlers/stream_handler_h.erl:-behavior(cowboy_stream). ./test/handlers/ws_init_h.erl:-behavior(cowboy_websocket). ./test/handlers/ws_dont_validate_utf8_h.erl:-behavior(cowboy_websocket). ./test/handlers/ws_info_commands_h.erl:-behavior(cowboy_websocket). ./test/handlers/ws_terminate_h.erl:-behavior(cowboy_websocket). ./test/handlers/ws_active_commands_h.erl:-behavior(cowboy_websocket). ./test/handlers/ws_deflate_opts_h.erl:-behavior(cowboy_websocket). ./test/handlers/ws_init_commands_h.erl:-behavior(cowboy_websocket). ./test/handlers/ws_shutdown_reason_commands_h.erl:-behavior(cowboy_websocket). ./test/handlers/ws_deflate_commands_h.erl:-behavior(cowboy_websocket). ./test/handlers/ws_ping_h.erl:-behavior(cowboy_websocket). ./test/handlers/ws_handle_commands_h.erl:-behavior(cowboy_websocket). ./test/handlers/ws_set_options_commands_h.erl:-behavior(cowboy_websocket). ./src/cowboy_stream_h.erl:-behavior(cowboy_stream). ./src/cowboy_compress_h.erl:-behavior(cowboy_stream). ./src/cowboy_decompress_h.erl:-behavior(cowboy_stream). ./src/cowboy_tracer_h.erl:-behavior(cowboy_stream). ./src/cowboy_tls.erl:-behavior(ranch_protocol). ./src/cowboy_metrics_h.erl:-behavior(cowboy_stream). ./src/cowboy_clear.erl:-behavior(ranch_protocol). ./plugins.mk:-behavior(cowboy_handler). ./plugins.mk:-behavior(cowboy_loop). ./plugins.mk:-behavior(cowboy_rest). ./plugins.mk:-behavior(cowboy_websocket).
4 -module(ws_handle_commands_h). W 5 -behavior(cowboy_websocket). % W: behaviour cowboy_websocket undefined 6 Issue in included file (18): behaviour cowboy_sub_protocol undefined 7 (Compiler L0000)
- Custom behaviours not recognized #8
For example from here:W 3 -behaviour(bhv). % W: behaviour bhv undefined
- intellij-erlang
From here aaronlelevier claims that
" This happened to me because I didnβt correctly use-callback
."
"
In the examples above, the definitions of the βcallbackβ attribute correspond to so that
"
The contracts specified with -callback attributes in behaviour modules can be further refined by adding -spec attributes in callback modules. This can be useful as -callback contracts are usually generic.
β¦
Each -spec contract is to be a subtype of the respective -callback contract.
"
See 6.3 User-Defined Behaviours - How to create and use a custom Erlang behavior?
The same thing happens for an example from hereW 2 -behavior(my_behavior). % W: behaviour my_behavior undefined
- Emakefile - custom behaviour undefined
I suppose this workaround is suitable for this case, but it doesnβt work for me.code_path_extra_dirs: - "./_build/default/lib/*/ebin/"
- βWarning: behaviour X undefinedβ, one release different apps #1444
I have 2 app, but one is written in C, and the other in Erlang.
Therefore, I think this workaround is not suitable for me:
"
Have you ensured thatapp2
hasapp1
in its.app.src
βsapplications
tuple? That order is used by the compiler to ensure proper compilation order.
"
Maybe it has something to do with Artifacts?
What I use:
-
Rebar3
β― rebar3 -v rebar 3.22.0 on Erlang/OTP 27 Erts 14.3
-
erlang_ls
β― erlang_ls -v Version: 0.49.0
-
local erlang_ls.config for rebar3 umbrella project from here https://erlang-ls.github.io/configuration/
β― cat erlang_ls.config apps_dirs: - "apps/*" deps_dirs: - "_build/default/lib/*" include_dirs: - "apps" - "apps/*/include" - "_build/default/lib/" - "_build/default/lib/*/include" code_path_extra_dirs: - "_build/default/lib/*/ebin/"
I would be grateful for answers.