How I upgraded to Elixir v1.4.0 on Ubuntu

Elixir Upgrading is so Simple in Ubuntu and It worked for me
Ubuntu 16.04

git clone https://github.com/elixir-lang/elixir.git
cd elixir/
git checkout v1.4
make clean test
sudo make install

In case if you already cloned, then you need to pull the code as git pull from the elixir directory

well. Don’t get too excited about your set up.

You have not upgraded Ubuntu-shipped elixir this way. The proper way of doing it would be by installing a DEB package.

You have installed elixir the manual way. Which means it’s installed without any dependencies and thanks to $PATH priority you are using newer version of Elixir. But the old one is also in the system.

I do not think this is proper set up and if you install packages this way, you will have trouble in the long run.

You can install packages provided by Erlang Solutions as instructions show here: https://www.erlang-solutions.com/resources/download.html

These are for both: Elixir and Erlang. Uninstall the system-provided versions, add those repositories and install what you need. They will update nicely.

Having said that, they don’t have ELixir 1.4 released just yet. It will take them a few days at least to do so I think.

You also have the option to use version manager, that is independent from system packages. I use asdf https://www.erlang-solutions.com/resources/download.html

The version manager allows you to have multiple versions of Erlang, Ruby, Node or Elixir installed at the same time and switch between those on per-project basis. Very useful if you run more than one project. I highly recommend you going this route.

4 Likes

Thanks a lot for everything. :bouquet: :bouquet:
But people who want to taste immediately elixir v1.4 can go with this I think, If I am not wrong.

Sure. You also do not really have to do make install, so it never installs elixir in system. Just run make and set up $PATH correctly so it uses the elixir from the build destination directory. It will work.

1 Like

I’m using asdf myself, which @hubertlepicki mentioned; it’s really simple to get started with, as can be seen in the instructions on GitHub. For Ubuntu, given that you already have Erlang/OTP installed, it would end up something like this:

# Install 'asdf' itself
git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.2.1
echo -e '\n. $HOME/.asdf/asdf.sh' >> ~/.bashrc
echo -e '\n. $HOME/.asdf/completions/asdf.bash' >> ~/.bashrc

# Add Elixir plugin
asdf plugin-add elixir https://github.com/asdf-vm/asdf-elixir.git

# Activate in current shell
. $HOME/.asdf/asdf.sh

# Install Elixir 1.4 & make it global default
asdf install elixir 1.4.0
asdf global elixir 1.4.0

Only the last two commands are needed, of course, if you already use asdf.

This way, you’ll have a nice setup where you can switch between any number of Elixir versions, set a global default, and set a project-level default that will be used whenever you’re in that project directory…

Nonetheless, I’ll say that it’s valuable to know how to install Elixir from source without any additional tooling as well :wink: Bonus points for compiling OTP, too, but there are a few more dependencies to think about there, if you want the end result to be full-featured.

1 Like

The last time I took a look at asdf it was neither capable of using a preinstalled system version nor was it able to install arbitrary tags/branches/SHAs from git.

This was really a showstopper for me, has this changed for elixir and erlang?

For Elixir, it seems to download releases only, but definitely makes use of preinstalled system version of Erlang/OTP just fine.

If I recall correctly, kiex does a better job there, at least handling arbitrary branches (haven’t tested anything else). However, I’m usually not interested in anything except released Elixir versions (unless it’s for pure experimentation, in which case I can clone the repo and compile it myself).

The major selling point of asdf for me, has been the .tool-versions file we can keep in our repository to 1) automatically use the specified Elixir version whenever we’re in the project directory, and 2) make sure everyone in the team is on the same version without complicating matters further.

@NobbZ, do you know of any other option that would provide the same conveniences but allow what you’re after - to install any tag/branch/SHA?

Nope I do not know such a tooling… That’s the main reason why I still have some curiosity about the direction it takes.

For OTP/Elixir use instruction from https://www.erlang-solutions.com/resources/download.html to have the latest version with autoupdate.

asdf .tool-versions documentation mentions that you can specify a version like ref:master or even path:location. I’m using the later to keep a local elixir dev version for myself.

2 Likes

I didn’t know it can do it <3. As @NobbZ I thought it was lacking that feature, probably was true in the early days.

I like this version manager specifically for the reason that with one .tool-versions file you can specify all your requirements for say, Ruby, Elixir, Node and Erlang in one place. This is perfect for me :slight_smile: