AstonJ

AstonJ

How members have set up their Elixir dev environment

With a few questions relating to this recently, I wonder if it might help having a thread where we share how we’ve set up Elixir/Erlang/Phoenix, etc. (Perhaps we can move it to #learning-resources:tutorials-guides-tips later?)

If you’ve set up your dev environment the same as someone else, please don’t forget to like their post!

If possible, please include:

  • Brief description. Please include your OS and tools used (such terminal app, whether you use ZSH, etc)
  • Steps to achieve the same set-up (the more complete this is the more helpful it could be to others)
  • What you like about the way you have set up your Elixir dev environment
  • Anything you might not like about it
  • Any other info you’d like to share

:slight_smile:

PS, for reference, here is the official install guide on the Elixir site, and the Phoenix install guide here.

Most Liked

dch

dch

basics:

  • OS: FreeBSD everywhere desktop laptop & servers
  • FreeBSD jails and zfs snapshots for lighweight testing and deployment
  • dtrace on FreeBSD and recon for debugging and tracing BEAM apps live. I’ve never needed pry & friends.
  • haproxy on my computer to redirect http requests and databases to whatever jail is actually running at that time
  • urxvt terminals appropriately titled for the task at hand, i3 for window manager, fish shell
  • devel/zeal: an offline docs browsing tool
  • git-cola: super graphical git commit tool for unix

BEAM

  • lang/elixir, rebar, rebar3, mix, hex all installed from FreeBSD packages
  • installed lang/erlang, erlang-runtime19, erlang-runtime20, lang-erlang-runtime21 all from packages (yes you can have them concurrently installed)
  • I switch between the erlang versions with a simple set PATH /usr/local/lib/erlang20/bin $PATH where needed. I cannot tell you how nice this is.
  • the packages are upgraded regularly usually 1-2 days after official OTP and elixir releases so you’re always patched without stress

editor

  • neovim with vim-plug, alchemist, vim-mix, vim-mix-format, network, a bunch of std tpope vim plugins (commentary, fugitive, sensible, projectionist), all the vim-erlang/* plugins, rainbow, vim-better-whitespace, ctrlp
  • I also have intellij-ultimate which I use for “larger” project management - moving stuff between files, its nice to use the mouse with tabs and many files sometimes

comms

  • irc via irccloud.com or hexchat
  • slack & hipchat for work-related stuff

workflow

I typically have a couple of windows open - a running elixir app on the left pane in a while loop, so I just need to ctrl-C to have it restart if needed.

mix clean; while mix format
  iex --name hive --cookie yum -S mix
  clear
end

and in that one I use ConCache to “copy” interesting data from the running program into the iex repl to play with. I often have network ports and pids in the values, so having real ones to play with is critical. this looks like this:

iex(hive@wintermute.skunkwerks.at)4> conn = ConCache.get(:webhook_cache, :req) 
%Plug.Conn{
  adapter: {Plug.Adapters.Cowboy.Conn,
   {:http_req, #Port<0.1471292>, :ranch_tcp, :keepalive, #PID<0.18751.0>,
    "POST", :"HTTP/1.1", ...

iex(hive@wintermute.skunkwerks.at)6> conn |> Plug.Conn.get_req_header("x-real-ip")

You can then do all the nice stuff right there in the repl! When I have the rough form of the desired function or module working, I switch over to vim in the right side window, write tests around my desired behaviour, throw in the code from IEx into a module, and profit.

The conn above is captured using a little Plug I shift around inside the app while I’m fiddling:

defmodule CapnHook.Debug do
  @moduledoc """
  Pretty Print the conn with nice colours
  """

  @highlighting [number: :yellow, atom: :cyan, string: :green, nil: :magenta, boolean: :magenta]

  use Plug.Builder

  def call(conn, _opts) do
    ConCache.put(:webhook_cache, :conn, conn)
    IO.inspect(conn, label: __MODULE__, syntax_colors: @highlighting, width: 0)
    conn
  end
end

In my final pane, I run a syslog tail on top, and a small window on bottom with mix test --trace --no-deps-check --stale until it’s all good.

then switch over to git-cola, order some smaller commits, do the distillery dance to produce a release, and I have a small script that turns that tarball into a deployable FreeBSD package.

If anybody’s interested in more details, message me, and I’ll spin this into an actual blog post.

16
Post #9
kokolegorille

kokolegorille

For Mac OSX (High Sierra)

Homebrew & Postgresql

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew doctor
brew install postgresql
ln -sfv /usr/local/opt/postgresql/*.plist ~/Library/LaunchAgents
brew services start postgresql
createuser -s postgres

Elixir/Erlang

For Erlang/Elixir, the same asdf procedure as @ConnorRigby, but with

asdf install erlang 21.0.7
asdf global erlang 21.0.7
asdf install elixir 1.7.3-otp-21
asdf global elixir 1.7.3-otp-21

and for Mac, You need to

echo -e '\n. $HOME/.asdf/asdf.sh' >> ~/.bash_profile
echo -e '\n. $HOME/.asdf/completions/asdf.bash' >> ~/.bash_profile

Phoenix

For 1.4, not yet released

From anywhere in your disk, where You have your Elixir source code

git clone https://github.com/phoenixframework/phoenix
cd phoenix/installer
MIX_ENV=prod mix do archive.build, archive.install
cd ../../

Nothing fancy, just using README for each used tools. I also install node, yarn for the full Elixir environment.

PS. I also install XCode as a pre-requisite for the Mac.

Where Next?

Popular in Guides/Tuts Top

AstonJ
This blog post hit my timeline earlier, and I’ve also been learning about some fantastic Elixir related tips via @pragdave’s new online c...
New
WolfDan
So my main OS is Windows, I do must of my work with it, Elixir and vscode elixirls works just fine when you’re working only with elixir, ...
New
sergio
Wrote this guide on how to integrate DropzoneJS with Phoenix Liveview. Hope it helps someone out! Woah read that title again, what a ...
New
voltone
The EEF’s Security WG has released the first public draft of the Secure Coding and Deployment Hardening Guidelines for BEAM languages. “...
New
tobleron
Ok, so I am so excited to share with you the most interesting setup I have made for Elixir/Phoenix today. Why? Because if you trust me, i...
New
niku
I write an article Parameterized testing with ExUnit.The key concept is using ExUnit.Case.register_test/4 such as ExUnit.start() defmod...
New
kokolegorille
Hello dear alchemists, There was this question some days ago here about the deployment to a VPS. As I was in the process of deploying t...
New
jshprentz
Geoffrey Lessel’s 2019 book, Phoenix in Action, was written for Phoenix 1.4. I found that the book’s code examples did not match the cur...
New
anuragg
We finally have a Mix clustering guide to go with Phoenix deployment with Mix Releases. Deploy an Elixir Cluster with Mix Releases and l...
New
nietaki
Just a quick heads up: There seems to be a bug in Erlang/OTP 21.3, which can cause some errors when making http requests. If you’re using...
New

Other popular topics Top

marius95
Hello everyone, I try to use an Javascript Event Handler in my root.html.leex file. Therefore I created a function in the app.js file: ...
New
vrod
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors: [WARN] - (starship::utils): Executing command ...
New
grych
Hi folks, Few months ago I have announced the proof-of-concept of the library to manipulate the browsers DOM objects directly from Elixi...
639 52673 488
New
fayddelight
I tried installing elixir 1.11.2 erlang 23.3.4 via asdf in my zsh shell. Enabled the versions locally and globally. When I list them ...
New
klo
Got a question about when to concat vs. prepending items to list then reversing to achieve appending. So i know lists boil down to [1 | ...
New
komlanvi
Hi everyone, I was playing with phoenix liveView but I run into an issue. I have a form and want to validate each input text when the te...
New
axelson
This post is a wiki (feel free to hit the edit button near the bottom right of this post to add your own changes!) This post collects co...
239 48342 226
New
JorisKok
I have a server on AWS, and was running a load test using artillery. When looking at the Phoenix dashboard I see the Ports going to 100% ...
New
svb
Hi! Currently I want to submit a form by pressing the Enter key. However, since my input field is of type “textarea” this is just adds a...
New
sergio
Kind of like when jquery came out, it was super necessary. Existing drag and drop libraries have a bunch of baggage to support old browse...
New

Latest on Elixir Forum

Elixir Forum

We're in Beta

About us Mission Statement