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.

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

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

2 Likes

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.

6 Likes

Typically Vagrant VMs (debian) provisioned by Ansible (conditionally ansible and ansible_local provisioners). Didn’t go for Docker as we have a mix of Windows, Linux and Mac, and Docker wasn’t a good option at the time. Usually use the erlang-solutions apt repo because I’m lazy and dont think we currently have a need for multiple Elixir versions yet. Ansible playbooks are split into roles and the same roles are used for dev and prod (or will be).

Code is mounted into the VM, typically at /vagrant, all code editing on the host (usually Neovim). Only thing I’ve not really got around to sorting is language server integration into the VM. Perpetually on the todo list :confused:

1 Like

Macbook air(8GB RAM, 128GB Storage) with MacOS High Sierra

3 Likes
1 Like

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 Likes

At work, I’ve got two Lenovo laptops: one with Ubuntu and one with Windows 10. At home, I’ve got a MacBook Pro, and a Raspberry Pi which I intend to use for playing with Nerves at some point.

My setup is nothing special; I install Erlang and Elixir via package managers, except on Windows, where I use the standard web installer. To edit code, I use Visual Studio Code and terminals (iTerm2 with Oh My Zsh on Mac) on all platforms (except on the Raspberry Pi, of course). I was using Vim for everything for the longest time, but have (surprisingly) been swayed to Visual Studio Code.

For syncing code across machines, I have Git repos on my own private server.

1 Like

My development environment is on Ubuntu 18 (I still use the Unity Desktop and run Ubuntu for desktops). The elixir package is installed using the OS installer and the postgresql from my os. For GUI I prefer the VS Code as is much lighter on resources than atom or eclipse I used before. I also like the docker integration.
All development is uploaded to a gitlab or bitbucket account for tracking purposes .
Releases are ensured using distillery with own Docker images based upon the builder pattern and the Arch Linux and the final release in deployed using docker compose.
At this time no CI is integrated but when I will needed it I will use the gitlab ci platform as the software is distributed using docker and docker compose and the Docker registry.
I find this to be the easiest solution to move from one machine to another (VS Code and Docker) but I do not use Docker for development in order to keep the hot auto-deploy part that I love about Elixir.

1 Like

I use a really simple environment based only on BSD systems (I used a lot of FreeBSD in the past).

1 Like

MacBook Pro 2015 (16GB, Mojave)

Erlang and Elixir (with asdf if I want to try new versions), otherwise via Homebrew.

Editor

IntelliJ Ultimate with Erlang and Elixir plugin
(I also try to get more into Emacs with erlang-mode and elixir-mode)

Terminal

iterm 2 and fish with a slide down window from top (and lots of tabs)

Version Control

Local git (cli) and GitHub (GitHub Desktop)

Datastore/Queues

Local/Remote PostgreSQL - Datagrip (Jetbrains)
Local/Remote RabbitMQ (internal web UI)

1 Like

I’m using vscode on macOS with Remote SSH to Ubuntu Server 18.04. I use asdf to install Elixir and Erlang on Ubuntu Server. But elixir-ls reports Failed to run 'elixir' command. ElixirLS will probably fail to launch. Logged PATH to Development Console. I checked the PATH in console, asdf path is not in it.

I tried to add . $HOME/.asdf/asdf.sh in ~/.profile and /etc/profile.d/asdf.sh , but both failed.

Does anyone has the same problem? Thanks

I’d be quite surprised if elixir-ls would support such a setup. It likely expects the elixir installation on the machine vs-code runs on.

  • Ubuntu
  • Installed Erlang and Elixir with ASDF
  • Visual Studio Code with ElixirLs and Vim plugins

It really works if Erlang and Elixir are installed using deb packages from erlang-solution.com as they are installed in the /usr/bin directory, which is in the PATH.

ASDF cannot work because for some reason . $HOME/.asdf/asdf.sh doesn’t work, it seems vscode cannot run the command when using Remote SSH.