Install elixir from source on Travis-ci

So I’m trying to get automated testing running for elixir_sense but I’m running an issue. The tests only pass (currently) if Elixir is installed from source. So I want to see if I can install Elixir from source on Travis. Having not used Travis very much I’m not sure how to go about it. I know that you can add elixir: '1.7.0 to your .travis.yml to install elixir from a binary release, but I’m not sure about installing from source.

Of course I may also opt to get the test suite running without requiring a source-installation but I wanted to get everything setup on CI before that if possible.

1 Like

Installing elixir from source is actually quite simple if you have make and erlang. It’s basically cloneing the git repo and tell make to compile it.

As @LostKobrakai suggest, just compile elixir in the before_script/install section of an erlang based image.

Hmmm, no luck so far. Here is my current .travis.yml with some additional debug commands in it:

language: erlang

otp_release: 
  - '21.2'

before_script:
  - git clone https://github.com/elixir-lang/elixir.git
  - cd elixir
  - git checkout v1.7.1
  - make compile
  - rm -rf .git
  - make
  - sudo make install
  - cd ..

script:
  - ls
  - pwd
  - mix test

But mix test is failing with an error starting the logger:

=SUPERVISOR REPORT==== 17-Jan-2019::16:36:39.404684 ===
    supervisor: {local,'Elixir.Logger.Supervisor'}
    errorContext: start_error
    reason: noproc
    offender: [{pid,undefined},
               {id,'Elixir.Logger.ErrorHandler'},
               {mfargs,
                   {'Elixir.Logger.Watcher',watcher,
                       [error_logger,'Elixir.Logger.ErrorHandler',
                        {true,false,500},
                        link]}},
               {restart_type,permanent},
               {shutdown,5000},
               {child_type,worker}]
Full Output of mix test
$ mix test
=SUPERVISOR REPORT==== 17-Jan-2019::16:36:39.404684 ===
    supervisor: {local,'Elixir.Logger.Supervisor'}
    errorContext: start_error
    reason: noproc
    offender: [{pid,undefined},
               {id,'Elixir.Logger.ErrorHandler'},
               {mfargs,
                   {'Elixir.Logger.Watcher',watcher,
                       [error_logger,'Elixir.Logger.ErrorHandler',
                        {true,false,500},
                        link]}},
               {restart_type,permanent},
               {shutdown,5000},
               {child_type,worker}]
=CRASH REPORT==== 17-Jan-2019::16:36:39.404631 ===
  crasher:
    initial call: Elixir.Logger.Watcher:init/1
    pid: <0.90.0>
    registered_name: []
    exception exit: noproc
      in function  gen:do_for_proc/2 (gen.erl, line 228)
      in call from gen_event:rpc/2 (gen_event.erl, line 239)
      in call from 'Elixir.Logger.Watcher':init/1 (lib/logger/watcher.ex, line 66)
      in call from gen_server:init_it/2 (gen_server.erl, line 374)
      in call from gen_server:init_it/6 (gen_server.erl, line 342)
    ancestors: ['Elixir.Logger.Supervisor',<0.84.0>]
    message_queue_len: 0
    messages: []
    links: [<0.85.0>]
    dictionary: []
    trap_exit: false
    status: running
    heap_size: 376
    stack_size: 27
    reductions: 253
  neighbours:
=CRASH REPORT==== 17-Jan-2019::16:36:39.416703 ===
  crasher:
    initial call: application_master:init/4
    pid: <0.83.0>
    registered_name: []
    exception exit: {{shutdown,
                         {failed_to_start_child,'Elixir.Logger.ErrorHandler',
                             noproc}},
                     {'Elixir.Logger.App',start,[normal,[]]}}
      in function  application_master:init/4 (application_master.erl, line 138)
    ancestors: [<0.82.0>]
    message_queue_len: 1
    messages: [{'EXIT',<0.84.0>,normal}]
    links: [<0.82.0>,<0.43.0>]
    dictionary: []
    trap_exit: true
    status: running
    heap_size: 376
    stack_size: 27
    reductions: 193
  neighbours:
=INFO REPORT==== 17-Jan-2019::16:36:39.417765 ===
    application: logger
    exited: {{shutdown,
                 {failed_to_start_child,'Elixir.Logger.ErrorHandler',noproc}},
             {'Elixir.Logger.App',start,[normal,[]]}}
    type: temporary
** (Mix) Invalid Elixir version requirement ~> 1.5 in mix.exs file
The command "mix test" exited with 1.

The full travis run can be viewed here: https://travis-ci.com/axelson/elixir_sense/builds/97716464

Also puzzling is the last line of output:

** (Mix) Invalid Elixir version requirement ~> 1.5 in mix.exs file

But it isn’t an invalid requirement… I would expect something more like what I get if I set the requirement to ~> 1.8:

** (Mix) You're trying to run :elixir_sense on Elixir v1.7.1 but it has declared in its mix.exs file it supports only Elixir ~> 1.8

I’ll take a closer look from home.

1 Like

Okay, solved it.

It seems as if due to restriction of how travis CI works, elixir isn’t really installed after running make install.

After I changed the script to use the elixir directly from the source folder, it worked. Also I prepared the git checkout already in a way, that you should be able to create a build matrix easily.

Latest build log: https://travis-ci.com/axelson/elixir_sense/builds/97754187
PR: https://github.com/axelson/elixir_sense/pull/1

3 Likes

Wow, thanks for seeing that through. I’ll get it merged down soon (hopefully later today).

1 Like

Here’s an updated example for anyone coming to this later (I had to remove any environment variables that depend on another environment variable):

language: erlang

otp_release:
  - '21.2'

env:
  EX_HOME: ${TRAVIS_BUILD_DIR}/elixir
  EX_BIN: ${TRAVIS_BUILD_DIR}/elixir/bin
  EX_VSN: 1.7.1

before_script:
  - git clone https://github.com/elixir-lang/elixir.git ${EX_HOME}
  - pushd ${EX_HOME}
  - git checkout v${EX_VSN}
  - make
  - popd
  - ${EX_BIN}/elixir ${EX_BIN}/mix local.hex --force
  - ${EX_BIN}/elixir ${EX_BIN}/mix local.rebar --force

script:
  - ${EX_BIN}/elixir ${EX_BIN}/mix deps.get
  - MIX_ENV=test ${EX_BIN}/elixir ${EX_BIN}/mix deps.compile
  - ${EX_BIN}/elixir ${EX_BIN}/mix test