Using Elixir 1.7 can I specify formatter to use the version from Elixir 1.6?

I have open source projects and I want to enforce formatting checks with CI.

I use Elixir 1.7 but I don’t really want to yet force contributors to upgrade to 1.7 in order to contribute code. Is there any way around this?

The formatter is part of the base Elixir distribution and makes use of standard parts of the compiler such as the parser. As a result it’s not possible to specify which version to use.

I think no matter what option you take here you’re going to have problems. If you use Elixir 1.6’s formatter on CI your Elixir 1.7 using contributors will be the ones that have the incorrect formatter version.

I would pick a version and have contributors use a tool such as asdf to manage versions, or instead make invalid format warn rather than error and then fix it yourself.

1 Like

I don’t think there is a problem having more stringent requirements for contributors than for users. This is very typical in many projects, that additional tools, practices etc have to be used in order to make a contribution. So for example if you use a travis compatibility matrix to run your tests on multiple versions of OTP/Elixir, I’d only run the format check on one specific version and put that information in the contribution guidelines. And @Ipil’s suggestion of asdf is good as well - use a .tool-versions file to specify the same version of Elixir that you run your format check on. Contributors just have to do an asdf install in your repo, and everything will work for them with the proper version.

I don’t think 1.7 involved new compiler warnings that can be fixed with mix format, but its possible a future Elixir version could which might mean that in practice you will end up running format with the latest Elixir that you are currently supporting.

3 Likes

Okay, thanks guys.

I guess I’ll just keep it at 1.7.

I’ve been meaning to look into asdf for a while and haven’t got around to that either.

1 Like

Agree with the above statements. With a tool like asdf it takes a few commands to get up and running.

1 Like