Hermanverschooten
Is there a way to see what version of a depency is loaded?
Gettext released a new version (0.26) that breaks compatibiliy, the way you need to add/use Gettext has been changed.
While it isn’t a problem for my project to make the necessary changes, it also breaks compilation for Timex.
Now I was wondering how one can distinguish in library code what version of Gettext is loaded, so the correct import vs use can be compiled.
Most Liked
Hermanverschooten
Yes I saw it too.
Although I must admit that I took the opportunity to remove Timex from my project and replace it with Elixir native functions and modules.
The only thing missing was Timex.between? and that was easily resolved.
allenmaxd
you can check the version of a dependency like Gettext that’s loaded at runtime using the Application.spec/2 function. Here’s how you can do it:
defmodule VersionCheck do
def gettext_version do
case Application.spec(:gettext, :vsn) do
'0.26.0' -> :new_version
_ -> :old_version
end
end
end
This function retrieves the version of Gettext and allows you to distinguish between different versions, enabling you to conditionally apply the necessary changes in your code.
kip
@carlgleisner, you’ll still need to bring gettext/1 into scope by importing it - the message suggests it isn’t imported into that module. ie I don’t think the error is coming from ex_cldr in this case (but hey, wouldn’t be the first time I’ve been wrong!).
Somewhere you’ve got a module MyApp.Gettext. Then in MyAppWeb.Layouts there should be an import for MyApp.Gettext module I believe.
(thanks for the kind words)
Popular in Questions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance









