I recently submitted a PR for an open source Elixir project and the tests failed for older versions of Elixir because I (prematurely) changed the config files to use import Config instead of the older form use Mix.Config.
Elsewhere I have seen code that tests the version of Erlang:
if System.otp_release() >= "22" do
# do something
else
# do something the old way
end
but is there something similar to testing the version of Elixir being used? Or is there some better way to write config files so they can run on older and newer versions of Elixir? The following results in a compile error when I use it inside config/config.exs:
if System.version() >= "1.9.0" do
import Config
else
use Mix.Config
end
Well. you cannot compare Elixir versions like that. It works for OTP versions because it is just the string represetntation of an integer. Look at that when using Semver2 versions
I thinking the error is actually because import is lexical, so in order for it to work you’d have to duplicate your entire config (which I wouldn’t recommend)