John Skiles Skinner's portfolio

Getting started with Elixir and Phoenix

I've seen a lot of blog posts about getting started with a new language or framework that make the process seem like there were no dead ends or moments of confusion. Here was my expience, including the mistakes I made.

A false start

I started following the first google result, which is a tutorial in the official phoenix documentation.

During the first step, cloning a repository, I run into You are in 'detached HEAD' state and spend a while resolving that. Some packages then ask to be approved; this is not mentioned in the tutorial, but I assume that they should be approved. During the second step, creating a new application, I saw this error:

== Compilation error in file lib/phoenix/socket.ex ==
** (ArgumentError) Access is not a protocol, cannot derive Access for Phoenix.Socket

Looking up the error, it turns that the tutorial is out of date! As so often happens, that first google hit is not the best. Wouldn't it be nice if they noted that it was old documentation at the top of the page?

A better path

I experiment with switching to a newer document and it seems to work well. So, I include this information a GitHub discussion about this error. Not only does this contribute to the community of developers, it is a signpost I leave for myself if I somehow end up going down the same path again.

I get as far as building a database with mix ecto.create and discover that Postgres cannot be not found. I had to restart PostgreSQL with:

brew services stop postgresql
rm /usr/local/var/postgres/
brew services start postgresql

I tried running mix ecto.create again and this time saw error:

role "postgres" does not exist

The command createuser -s postgres resolves this. Re-running the creation attempt, the database is created!

This time mix phx.server ran without a hitch. Visiting localhost:4000 in my browser, I see Phoenix running! Altogether much easier than the first time that I set up Rails. I spent only a couple of hours, rather than a couple of days.

One setp onward

I contiunted on to the next step of that more up-to-date tutorial. I pasted in their code to add a new page to my project. I got this error:

module HelloWeb is not loaded and could not be found

I conclude that this is because I choose a different project name than the tutorial, so HelloWeb had to be transformed into PhoenixTestWeb in a number of locations to match the name of my project. Then I have a new working page!

The ease of setup makes me pretty enthusiastic about Phoenix. I'll be writing about it in the future I'm sure!

Top of page | Blog index | Return home