Skip to content

Commit 44ddb88

Browse files
committed
Add warning if OTP runtime version doesn't match the build version
1 parent 5afd375 commit 44ddb88

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

apps/els_lsp/src/els_general_provider.erl

+26
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ handle_request({initialize, Params}) ->
8484
ok = els_config:initialize(RootUri, Capabilities, InitOptions, lsp_notification),
8585
{response, server_capabilities()};
8686
handle_request({initialized, _Params}) ->
87+
ok = check_version(),
8788
RootUri = els_config:get(root_uri),
8889
NodeName = els_distribution_server:node_name(
8990
<<"erlang_ls">>,
@@ -109,6 +110,31 @@ handle_request({exit, #{status := Status}}) ->
109110
%%==============================================================================
110111
%% API
111112
%%==============================================================================
113+
-spec check_version() -> ok.
114+
check_version() ->
115+
RuntimeVersion = list_to_integer(erlang:system_info(otp_release)),
116+
BuildVersion = ?OTP_RELEASE,
117+
case RuntimeVersion == BuildVersion of
118+
true ->
119+
ok;
120+
false ->
121+
Message = els_utils:to_binary(
122+
io_lib:format(
123+
"Running Erlang/OTP ~p, but compiled with Erlang/OTP ~p.\n"
124+
"If you experience issues, "
125+
"please recompile Erlang LS using Erlang/OTP ~p.",
126+
[RuntimeVersion, BuildVersion, RuntimeVersion]
127+
)
128+
),
129+
?LOG_WARNING(Message),
130+
els_server:send_notification(
131+
<<"window/showMessage">>,
132+
#{
133+
type => ?MESSAGE_TYPE_WARNING,
134+
message => Message
135+
}
136+
)
137+
end.
112138

113139
%% @doc Give all available providers
114140
-spec available_providers() -> [provider_id()].

0 commit comments

Comments
 (0)