jc00ke

jc00ke

A way to get the exact OTP_VERSION w/o using a dependency?

Before I propose this to the core team via mailing list, does anyone know of the incantation to get the exact OTP version? I’ve found otp_version and I see that –short-version will land in 1.13, but I’d really like to see the actual OTP_VERSION.

iex(1)> System.version()
"1.12.1"
iex(2)> System.otp_release()
"24"
iex(3)> System.build_info()
%{
  build: "1.12.1 (compiled with Erlang/OTP 24)",
  date: "2021-05-28T16:00:08Z",
  otp_release: "24",
  revision: "42807d2",
  version: "1.12.1"
}
iex(4)> :erlang.system_info(:otp_release)
'24'

My motivation is that there can be a discrepancy between what I have in .tool-versions and what’s installed in a Docker container and I’d like CI to fail if versions don’t match. Ideally CI would fail quickly with a bash script in the test pipeline instead of needing to compile the whole project.

Thanks!

Most Liked

wojtekmach

wojtekmach

Hex Core Team

This is what mix hex.info uses:

moogle19

moogle19

Here is some documentation about it:
Retrieving current OTP version

The elixir version would look something like this:

[:code.root_dir(), "releases", :erlang.system_info(:otp_release), "OTP_VERSION"] 
|> Path.join() 
|> File.read!() 
|> String.trim()
wojtekmach

wojtekmach

Hex Core Team

You’d have to ask the core team but I’m pretty sure the answer would be no unless there’s a proper API in OTP for it, I imagine something like :erlang.system_info(:otp_version) would be one idea how this could be exposed. But yeah, the versioning is tricky as described in one of the links above.

Where Next?

Popular in Questions Top

JDanielMartinez
Hi! May someone helps me, please! I have two apps into an umbrella project: the first one is Database, which manages queries, and the se...
New
JorisKok
I have a server on AWS, and was running a load test using artillery. When looking at the Phoenix dashboard I see the Ports going to 100% ...
New
Jim
As a follow up to my earlier question: I have the code compiling and running but not getting a successful login from the rest server. ...
New
nsuchy
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
vertexbuffer
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
freewebwithme
Using vs code and installed ElixirLS: support and debugger. And I got an error popped up on start up says Failed to run ‘elixir’ comma...
New
mgjohns61585
Could someone help me? I'm making my first elixir program, number guessing game. I can't figure out how to convert the user's guess from ...
New
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
Mooodi
Given a string, how can I get access to its character by index? Enum.at("my_string", 2) doesn't work. Or rather, not char, but a substr...
New
romenigld
I am trying to run a deploy with docker and I successfully runned with this command: docker build -t romenigld/blog-prod . but when I t...
New

Other popular topics Top

dotdotdotPaul
Okay, I'm having a heck of a time trying to figure out how to best handle the validation of belongs_to associations in Ecto. I'm sure I'...
New
William
I would like to know that is there any online source for learning Phoenix Framework for building E-Commerce Store? Any advantage on build...
New
sergio
I couldn’t find any guides that worked well with Phoenix 1.6.0 and esbuild. I hope this helps people test the waters and eases you into t...
New
_russellb
I want to try my hand at web scraping. What tools/libraries do I need to use. I’m hoping to turn this into something professional so don’...
New
freewebwithme
Using vs code and installed ElixirLS: support and debugger. And I got an error popped up on start up says Failed to run ‘elixir’ comma...
New
minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
vonH
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
electic
Hi, I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
WestKeys
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New
romenigld
I am trying to run a deploy with docker and I successfully runned with this command: docker build -t romenigld/blog-prod . but when I t...
New

We're in Beta

About us Mission Statement