Skip to content

Commit fdbf0ef

Browse files
committed
rabbit_runtime: Improve get_erl_path/0
[Why] The previous implementation assumed that ERTS was in the Erlang root dir. This is true for a standard Erlang install. However, it's not the case of an Erlang release that does not include the runtime. [How] The bin directory (`bindir`) is already available as an argument to init. We can simply query it and use the value as is.
1 parent 0ea9395 commit fdbf0ef

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

deps/rabbit_common/src/rabbit_runtime.erl

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,10 @@ msacc_stats(TimeInMs) ->
5656
% get the full path to the erl executable used to start this VM
5757
-spec get_erl_path() -> file:filename_all().
5858
get_erl_path() ->
59-
ERTSDir = rabbit_misc:format("erts-~ts", [erlang:system_info(version)]),
60-
Bin = filename:join([code:root_dir(), ERTSDir, "bin"]),
59+
{ok, [[BinDir]]} = init:get_argument(bindir),
6160
case os:type() of
6261
{win32, _} ->
63-
filename:join(Bin, "erl.exe");
62+
filename:join(BinDir, "erl.exe");
6463
_ ->
65-
filename:join(Bin, "erl")
64+
filename:join(BinDir, "erl")
6665
end.

0 commit comments

Comments
 (0)