VlkrS

VlkrS

Working with Phoenix on OpenBSD (tailwind, esbuild)

Note: This is a HOWTO, not a question. I hope this is an appropriate place to share this, so it can be found by others who might run into problems getting Phoenix to work fully on OpenBSD.

Recent versions of Phoenix are tightly integrated with both TailwindCSS and esbuild, and mix phx.new installs binary distributions of both.
Unfortunately that doesn’t work out of the box on OpenBSD, and needs a few extra steps to be carried out right after initializing a project.

Tailwind

The automatically installed Linux binary obviously will never work on OpenBSD. Therefore we will need to manually install tailwind:

First install NodeJS:

$ doas pkg_add node

then Tailwind and the Forms plugin:

$ npm install -D tailwindcss
$ npm install -D @tailwindcss/forms

It’s possible that this creates a version mismatch between the version of tailwind installed by npm and the version from the default configuration. If that’s the case, just adjust the version in config/config.exs:

...
# Configure tailwind (the version is required)
config :tailwind,
  version: "<your version here>",
...

now all that’s left is to replace the binary _build/tailwind_linux_x64:

$ > _build/tailwind_linux_x64

with a small shell script

#!/bin/sh

npx tailwindcss "$@"

At this point we’re done. All the Tailwind integrations will now work on OpenBSD in the same way as on Linux.

esbuild

Those working with 11th gen or later Intel CPUs will notice that the esbuild binaries released by the esbuild team will crash on OpenBSD.
(see Install fails on OpenBSD · Issue #3523 · evanw/esbuild · GitHub for details)

Fortunately that’s also easy to fix by building esbuild with OpenBSDs patched go compiler and copying the resulting binary over _build/esbuild_openbsd_x64.

First Post!

krasenyp

krasenyp

Run all the things on *BSD! Thank you for the guide!

Most Liked

VlkrS

VlkrS

Update: Starting with OpenBSD 7.7-current, esbuild is provided as port.

Therefore, esbuild problems can be solved as simply as

$ doas pkg_add esbuild
$ ln -s /usr/local/bin/esbuild _build/esbuild-openbsd-x64

on affected systems.

krasenyp

krasenyp

I think it’s time to sit down and write a tutorial on packaging Elixir releases as FreeBSD ports. It allows installation as just another program and one can easily distribute them with a custom port repository.

LostKobrakai

LostKobrakai

Last Post!

VlkrS

VlkrS

The OpenBSD version is irrelevant here. More recent versions of Phoenix use Tailwind v4, Tailwind v4 uses Parcel, Parcel wants to install a binary but doesn’t provide said binary for OpenBSD.

Phoenix itself works, but Tailwind version 4 doesn’t.

Where Next?

Trending in Questions Top

jonnycharles
I’m in search of an Elixir library that offers PDF generation capabilities similar to Ruby’s Prawn. While there have been discussions abo...
New
spammy
I’m looking to build a personal workflow to quickly deploy web applications written in elixir/phoenix, for local consumption (ie not on t...
New
silverdr
Using Phoenix.LiveView.TagEngine as an EEx.Engine is deprecated! To compile HEEx, use Phoenix.LiveView.TagEngine.compile/2 instead. Sta...
New
saveman71
Hello ! We want new/edit form pages to POST/PUT to their own URL rather than the resources REST defaults (post /things, put /things/:id)...
New
dli
Before I dive in myself, did anyone successfully sprinkle Hologram into their existing LiveView app? Looking for hints regarding: Addi...
New
bottlenecked
Hi all, I wanted to ask how the community is dealing with post-release steps. Today we have Ecto migrations, which make sure that the db...
New
michallepicki
I am using Oban and occasionally, shortly after a deployment, a handful of jobs can fail because of dependency on other parts of the syst...
New

Other Trending Topics Top

JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Damirados
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge &amp; Solve. They are GUI (Emerge) and State management (S...
New
ausimian
Emily is an Elixir library that runs Nx computations on Apple’s MLX. Install it as the default Nx backend and Nx, defn, Axon, Nx.Serving,...
New
type1fool
I just stumbled on a newly redesigned elixir-lang.org. :tada: It looks like @Software_Mansion did the work, and I think it is generally a...
New
akoutmos
@hugobarauna and I (Alex Koutmos) have been hard at work on writing a book on Nerves that takes you from simply blinking LEDs to building...
New

We're in Beta

About us Mission Statement