Writing an Elixir App


#1

Elixir is a functional programming language that builds off of Erlang. Cloud9 provides syntax highlighting for Elixir files and setting up an Elixir environment with Cloud9 is doable with the following instructions and commands:

  1. Create a new workspace.
  2. Select the “Blank” template (or any template will work).
  3. When the workspace loads, run the following commands in the terminal:
# For some reason, installing Elixir tries to remove this file
# and if it doesn't exist, Elixir won't install. So, we create it.
sudo touch /etc/init.d/couchdb

# Standard Ubuntu Elixir installation instructions
wget https://packages.erlang-solutions.com/erlang-solutions_1.0_all.deb
sudo dpkg -i erlang-solutions_1.0_all.deb
sudo apt-get update
sudo apt-get install elixir

Now Elixir is installed and ready to run. Go ahead and create a new .exs file, you could call it hello.exs. Open the file and paste the following code for a simple hello world:

IO.puts "Hello world from Elixir"

Open the terminal and run elixir hello.exs and you should see the following output:

Hello world from Elixir

Now you’ve got your first Elixir program going and you’re ready to write more Elixir! iex, elixir, and mix should all be available and Cloud9 has syntax coloring for Elixir code. Happy coding!


Thanks to @donwb for this thread that clarifies some things and to @dberkom for his original tutorial at How to Run Elixir on Cloud9 IDE.


Tutorials - Table of Contents
#2

#3

#4

Thanks for this - not working for me at the moment - I’m getting:

tansaku:~/workspace $ sudo apt-get install elixir
Reading package lists... Done
Building dependency tree       
Reading state information... Done
You might want to run 'apt-get -f install' to correct these:
The following packages have unmet dependencies:
 couchdb : Depends: couchdb-bin (>= 1.5.0-0ubuntu1) but it is not going to be installed
 elixir : Depends: erlang-base (>= 1:17.0) but it is not going to be installed or
                   erlang-base-hipe (>= 1:17.0) or
                   esl-erlang (>= 1:17.0) but it is not going to be installed
          Depends: erlang-crypto (>= 1:17.0) or
                   esl-erlang (>= 1:17.0) but it is not going to be installed
          Depends: erlang-inets (>= 1:17.0) or
                   esl-erlang (>= 1:17.0) but it is not going to be installed
          Depends: erlang-ssl (>= 1:17.0) or
                   esl-erlang (>= 1:17.0) but it is not going to be installed
          Depends: erlang-syntax-tools (>= 1:17.0) or
                   esl-erlang (>= 1:17.0) but it is not going to be installed
 erlang-nox : Depends: erlang-base but it is not going to be installed or
                       erlang-base-hipe
              Depends: erlang-asn1
              Depends: erlang-corba
              Depends: erlang-crypto
              Depends: erlang-diameter but it is not going to be installed
              Depends: erlang-edoc
              Depends: erlang-eldap but it is not going to be installed
              Depends: erlang-erl-docgen
              Depends: erlang-eunit
              Depends: erlang-ic
              Depends: erlang-inets
              Depends: erlang-mnesia
              Depends: erlang-odbc
              Depends: erlang-os-mon
              Depends: erlang-parsetools
              Depends: erlang-percept
              Depends: erlang-public-key
              Depends: erlang-runtime-tools
              Depends: erlang-snmp
              Depends: erlang-ssh
              Depends: erlang-ssl
              Depends: erlang-syntax-tools
              Depends: erlang-tools
              Depends: erlang-webtool
              Depends: erlang-xmerl
E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).

#5

According to the message, there are some unmet or missing dependencies. At the end, it recommends running apt-get -f install. This will install all unmet dependencies for you, and should resolve the problem.


#6

Thanks dannytech - I tried that already and it failed.

I’ve got it working now - I think the problem was I started following the Ubuntu install instructions here: http://elixir-lang.org/install.html

I just tried the instructions posted by the original author on a completely fresh workspace and it worked fine …


#7

I think the issue was just that couchdb init script was not found. I just ran
sudo touch /etc/init.d/couchdb
and then
sudo apt-get install elixir

and it worked fine.