Apologies to the Elixir community: 1.18 release now available
To our Elixir community members: we owe you an apology. While you’ve been enjoying the benefits of Elixir 1.17 and 1.18 releases, our platforms have been stuck in June 2023. That changes today. Elixir 1.18 is now officially available on both Upsun and Platform.sh.
What’s in Elixir 1.18?
If you haven’t been following the Elixir changelog, version 1.18 brings several significant improvements:
Type checking of function calls
The biggest update is expanded type checking capabilities. Elixir’s type system now checks function calls and gradually infers patterns and return types.
This means your code gets smarter validation without requiring explicit type annotations. For example, the system can now detect:
- Patterns that will never match any argument
- Accessing tuples at invalid indexes
- Branches in a
try
block that will never match - Attempting to use return values from functions like
raise/2
(which by definition never return)
The type system can even identify unused private function clauses, helping you clean up dead code.
Language Server improvements
Elixir 1.18 introduces compiler locks and listeners that improve how language servers interact with your code. Previously, your project would be compiled once for your use and again for the language server.
Now, the compiler lock ensures only one instance compiles your project at a time, while listeners allow different Elixir processes to share compilation results. This means better performance for your language servers, IEx, and Phoenix.
Built-in JSON support
Building on Erlang/OTP 27’s additions, Elixir 1.18 includes a native JSON
module with encoding and decoding functions. The API mirrors the popular Jason library, and includes a JSON.Encoder
protocol for customizing how your data types are encoded.
You can even derive the protocol for structs with a simple line:
@derive {JSON.Encoder, only: [:id, :name]}
defstruct [:id, :name, :email]
Parameterized tests and ExUnit groups
Testing gets more powerful with parameterized tests that run your test modules multiple times with different parameters. This is ideal for testing code that behaves differently based on configuration.
The new ExUnit groups feature allows more efficient concurrent testing. Tests with shared state can be assigned to the same group (preventing them from running concurrently with each other), while tests in different groups can run in parallel.
Using Elixir 1.18 on Platform.sh and Upsun
To start using Elixir 1.18 on your projects, update your .platform.app.yaml
or .upsun/config.yaml
file with the following runtime configuration:
type: 'elixir:1.18'
If you’re using Phoenix or another framework, ensure you’re also specifying the appropriate relationships and build hooks. Here’s an example for a Phoenix application:
applications:
myapp:
type: 'elixir:1.18'
variables:
env:
MIX_ENV: 'prod'
hooks:
build: |
mix local.hex --force
mix local.rebar --force
mix do deps.get --only prod, deps.compile, compile
web:
commands:
start: mix phx.server
locations:
/:
allow: false
passthru: true
Preview environments shine with Elixir
One of the advantages of using Elixir on Upsun is the ability to create preview environments for each branch of your repository. When you create a new branch, you get a complete clone of your production environment—including your database—allowing you to test new features in isolation.
For Elixir applications, this means you can safely test those complex Phoenix LiveView components or that new Ecto migration without worrying about breaking production.
Moving forward
Going forward, Platform.sh and Upsun will track the Elixir release cycle closely. No more waiting months for new Elixir versions to become available on the platforms. Each new stable Elixir release will be tested and made available promptly.
The improvements in 1.18 make this functional programming language even more powerful for building scalable, reliable applications, and you can count on having access to future improvements as they become available.
If you encounter any issues with the new Elixir 1.18 runtime, don’t hesitate to contact support through your Platform.sh or Upsun dashboard.
Happy coding!