fix: don't crash when OTP_VERSION file is missing
This commit is contained in:
parent
5783127c30
commit
6162f90610
|
@ -400,7 +400,7 @@ compat_windows(Fun) ->
|
||||||
end
|
end
|
||||||
end.
|
end.
|
||||||
|
|
||||||
%% @doc Return on which Eralng/OTP the current vm is running.
|
%% @doc Return on which Erlang/OTP the current vm is running.
|
||||||
%% NOTE: This API reads a file, do not use it in critical code paths.
|
%% NOTE: This API reads a file, do not use it in critical code paths.
|
||||||
get_otp_version() ->
|
get_otp_version() ->
|
||||||
read_otp_version().
|
read_otp_version().
|
||||||
|
@ -417,6 +417,8 @@ read_otp_version() ->
|
||||||
%% running tests etc.
|
%% running tests etc.
|
||||||
OtpMajor = erlang:system_info(otp_release),
|
OtpMajor = erlang:system_info(otp_release),
|
||||||
OtpVsnFile = filename:join([ReleasesDir, OtpMajor, "OTP_VERSION"]),
|
OtpVsnFile = filename:join([ReleasesDir, OtpMajor, "OTP_VERSION"]),
|
||||||
{ok, Vsn} = file:read_file(OtpVsnFile),
|
case file:read_file(OtpVsnFile) of
|
||||||
Vsn
|
{ok, Vsn} -> Vsn;
|
||||||
|
{error, enoent} -> list_to_binary(OtpMajor)
|
||||||
|
end
|
||||||
end.
|
end.
|
||||||
|
|
Loading…
Reference in New Issue