I hear more and more about Elixir from some people that I really trust and respect. That means checking-out-new-technology-time for Marcus.
Luckily installing Elixir on Os X (Yosemite 10.10, that I’m running) is super simple with Homebrew:
brew update
brew install elixir
Or is it …
Not for me as it turns out. I hope you had a better fate. This is my story.
Becasue when that was all done I ran elixir -v
to check my version number and got:
"{"init terminating in do_boot",{undef,[{elixir,start_cli,[],[]},{init,start_it,1,[]},{init,start_em,1,[]}]}}"
In the output from Homebrew I saw just a little warning but nothing that was particularly scary. So I did what every professional programmer does; searched the Internets. And on GitHub I found this issue for Elixir, which sounds exactly like that I was looking for.
Yak-shaving: Erlang
Ok… it seems like my version of Erlang, since Elixir “leverages the Erlang VM” was out of date.
But when I ran (in all honestly after I’ve spent ca 45 minutes finding out how to start anything Erlang): erl
, to run the Erlang interperator, it looked great:
Marcus-Bandung-MBP:~ marcus$ erl
Erlang R15B02 (erts-5.9.2) [source] [smp:4:4] [async-threads:0] [hipe] [kernel-poll:false]
Eshell V5.9.2 (abort with ^G)
1>
Erlang is doing great. Hmmm… Could it be a old version of Erlang? Erlang is also installed with Homebrew, so I tried to install it again and hopefully update it: brew install erlang
. Now it got interesting:
Marcus-Bandung-MBP:~ marcus$ brew install erlang
Warning: erlang-17.5 already installed, it's just not linked
Yak-shaving: Homebrew
Installing a package with Homebrew consists of several step: download, install and linking (I think). One of the steps has failed. This was the little warning I got when I installed Elixir as I mentioned above.
Luckily you can link
a package after it’s been downloaded. For example brew link erlang
, or to force it brew link --overwrite erlang
.
Marcus-Bandung-MBP:~ marcus$ brew link --overwrite erlang
Linking /usr/local/Cellar/erlang/17.5...
Error: Could not symlink lib/erlang/Install
/usr/local/lib/erlang is not writable.
And do not try sudo
in front of it. Homebrew doesn’t think that’s a good idea and tells you with a hilarious error message…
But what did it say? /usr/local/lib/erlang is not writable.
Maybe I can help it?
Yak-shaving: Os X
Ha! Writable my aXX! I can fix that: sudo chmod -R 777 /usr/local/lib/erlang
.
Sadly that didn’t help much. The linking command from above ( brew link --overwrite erlang
), still failed with the same error (/usr/local/lib/erlang is not writable
).
And the folder, and sub-folders (the -R
-switch), was indeed writable.
Yak = shaved clean
What to do? Well, out of a whiff I just tried: brew reinstall erlang
again. And it worked.
When you do a brew reinstall
the old installation is removed first. This basically just uninstall
and then directly install
a formula.
My thinking is that I had, for some reason, an older version of Erlang installed. Maybe even failed install. When Homebrew tried to install a new version of Erlang it failed, since the folders was not writable. When I made them writable the reinstall
worked.
Conclusion
Just for good measures I actually did a brew reinstall elixir
too. Just to make sure that the dependencies was in good order.
After that I could start coding Elixir. This is the full extent of my Elixir knowledge. Strap in:
Marcus-Bandung-MBP:~ marcus$ elixir -v
Elixir 1.0.4
Marcus-Bandung-MBP:~ marcus$ iex
Erlang/OTP 17 [erts-6.4] [source] [64-bit] [smp:4:4] [async-threads:10] [hipe] [kernel-poll:false] [dtrace]
Interactive Elixir (1.0.4) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)> 4+4
8
Yeah. This tool looks amazing!
Thanks to the Stockholm Elixir Slack-group that listen to me while I hammered away to fix this.