Question
Answer and Explanation
To check the version of Erlang installed on your system, you can use the Erlang shell or the command line. Here are the common methods:
1. Using the Erlang Shell (Erlang REPL):
- Open the Erlang shell by typing erl
in your terminal or command prompt.
- Once the shell is open, you can use the following command:
erlang:system_info(otp_release).
- This command will return the Erlang/OTP release version. For example, it might output something like "25"
or "26"
.
- Alternatively, you can use the following command to get more detailed information:
erlang:system_info(version).
- This command will return a string containing the full version information, such as "Erlang/OTP 25 [erts-13.2.2] [source] [64-bit] [smp:12:12] [ds:12:12:10] [async-threads:1] [jit]"
.
- To exit the Erlang shell, type halt().
and press Enter.
2. Using the Command Line:
- You can also check the Erlang version directly from your terminal or command prompt without entering the Erlang shell.
- Use the following command:
erl -version
- This command will output the Erlang version information to the console, similar to the output of erlang:system_info(version).
.
- Another command that can be used is:
erl -noshell -s init stop -eval 'io:format("~s~n", [erlang:system_info(version)]).'
- This command will print the version information and then exit.
Example Output:
- Using erlang:system_info(otp_release).
in the Erlang shell might return: "26"
- Using erl -version
in the command line might return: Erlang/OTP 26 [erts-13.2.2] [source] [64-bit] [smp:12:12] [ds:12:12:10] [async-threads:1] [jit]
By using either the Erlang shell or the command line, you can easily determine the version of Erlang installed on your system. This is useful for ensuring compatibility with libraries and applications that depend on specific Erlang versions.