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

Morzaram
Hey guys I’ve made a guide on how to connect Quill to Phoenix. For the sake of formatting it might be easier to view it on my Notion Doc...
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
dgamidov
Hi folks, Just a short instruction. Maybe it will help somebody. https://v4-alpha.getbootstrap.com/getting-started Install boostrap...
New
pinksynth
Whenever tests have to interact with an Ecto.Repo, sometimes it’s necessary to test a few different branches or paths that data can take....
New
crockwave
To integrate dropdown menus in a Phoenix Liveview app, you can use a combination of js, Hooks, CSS and your .leex and .ex code. You can...
New
water
I’ll post this here, It might help someone in the future. Feedback is greatly appreciated. I use it with direnv on NixOS, It should wor...
New
marcin
This post is intended to be a guide for others, I was running a remote debugger for the first time and appreciate feedback on how I could...
New
anuragg
We just published a guide to automatic clustering in Elixir 1.9, with Mix releases and libcluster. The cluster automatically discovers n...
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

jerry
Good day to you all. I have been struggling to get a query involving like and ilike to work. Can anyone assist me on this, please? pro...
New
Jim
As a follow up to my earlier question: I have the code compiling and running but not getting a successful login from the rest server. ...
New
fireproofsocks
I’m working on defining a simple Ecto schema for a table (in PostGres), but I don’t see where I can define a column as NOT NULL. Conside...
New
lastday4you
I wanted to check elixir version in phoenix because i found that my elixir is 1.5 but when i use Enum.chunk_by it said the function is un...
New
myronmarston
The Elixir Typespec docs show the following syntax for keyword lists in typespecs: # ... | [key: type] # keyword lis...
New
chensan
I have a User schema with a :from_id field set to type :string: defmodule TweetBot.Repo.Migrations.CreateUsers do use Ecto.Migration ...
New
rms.mrcs
Hi, I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list....
New
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
msaraiva
Surface is an experimental library built on top of Phoenix LiveView and its new LiveComponent API that aims to provide a more declarative...
564 42633 214
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

We're in Beta

About us Mission Statement