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.

ConnorRigby

ConnorRigby

Nerves Core Team

OS

Arch linux w/ I3 + FISH shell

Setup

git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.5.1
echo 'source ~/.asdf/asdf.fish' >> ~/.config/fish/config.fish
mkdir -p ~/.config/fish/completions; and cp ~/.asdf/completions/asdf.fish ~/.config/fish/completions
asdf plugin-add erlang https://github.com/asdf-vm/asdf-erlang.git
asdf plugin-add elixir https://github.com/asdf-vm/asdf-elixir.git
asdf install erlang 21.0.4
asdf install elixir 1.6.6-otp-21

Editor

Vim and sometimes Atom w/ no plugins

prio101

prio101

  1. OS - Ubuntu
  2. Erlang with package manager
  3. kiex for elixir installation
  4. vs code editor elixir plugin

Where Next?

Popular in Guides/Tuts Top

zachallaun
Hey friends, wanted to share a tiny shell script I’ve been using to start Livebook with easy access to either a running production server...
New
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
dgamidov
Hi folks, Just a short instruction. Maybe it will help somebody. https://v4-alpha.getbootstrap.com/getting-started Install boostrap...
New
berts-4865
Here is a quick guide to uploading a file from the browser to DO spaces. It is crude, but will hopefully save sometime time and frustrat...
New
hauleth
Some time ago someone suggested me to write article about how I have configured my Vim to work with Elixir, now there it is: https://med...
New
jtormey
Hello! Having written a lot of LiveView code, I’ve made some VS Code snippets to speed up writing callbacks for LiveViews and LiveCompon...
New
Jskalc
Sorry if it’s a common knowledge, but it’s something I just learned and wanted to share. I’ve seen that mind-blowing demo of hot-reload ...
New
KoviRobi
Hi, I’ve written the following to debug function calls, not sure if it’s useful for anyone else, and if so should I put it somewhere? i...
New
kevinlang
Hey all, With Phoenix 1.6 just around the corner, I figured I’d make a tutorial on how to add Bulma to a new Phoenix 1.6 project. By lev...
New

Other popular topics Top

chrisalley
ExUnit now has describe blocks which is a welcome addition coming from RSpec. In the docs, it states that nested hierarchies of describe ...
New
sorentwo
Hello! tl;dr Announcing Oban, an Ecto based job processing library with a focus on reliability and historical observability. After spen...
977 41022 311
New
dotdotdotPaul
Okay, I'm having a heck of a time trying to figure out how to best handle the validation of belongs_to associations in Ecto. I'm sure I'...
New
gshaw
What is the idiomatic way of matching for not nil in Elixir? E.g., First way: defp halt_if_not_signed_in(conn, signed_in_account) when...
New
_russellb
I want to try my hand at web scraping. What tools/libraries do I need to use. I’m hoping to turn this into something professional so don’...
New
KronicDeth
Elixir plugin for JetBrain’s IntelliJ Platform (including Rubymine) This is a plugin that adds support for Elixir to JetBrains IntelliJ...
289 35421 110
New
mgjohns61585
Could someone help me? I'm making my first elixir program, number guessing game. I can't figure out how to convert the user's guess from ...
New
vonH
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
johnnyicon
Hi all, I've just started learning Elixir and Phoenix Framework, so please pardon my n00bness at this stage. I'm trying to use Postg...
New
ovidiubadita
Hey all, I discovered Elixir and I love it. I always wanted to learn a functional programming and I intended to go for Haskell, but afte...
New

We're in Beta

About us Mission Statement