-sh: 12: Syntax error: “&” unexpected error when you build Elixir app with edeliver

This error looks like this:

-sh: 12: Syntax error: "&" unexpected
ssh -o ConnectTimeout=3 [email protected] 
set -e
    if [ ! -d /home/bots/apps/builds ]
    then
      mkdir -p /home/bots/apps/builds
      cd /home/bots/apps/builds
      git init &> /dev/null
      git config receive.denyCurrentBranch ignore
    else
      cd /home/bots/apps/builds
      git config receive.denyCurrentBranch ignore
    fi
   &> /dev/null$

This simple dummy error means that you have different shell on your build host.
I created a user “bot” on my DigitalOcean VPS and user’s shell was `sh` by default.
So I logged in to the build host and changed shell like `chsh /bin/bash`.
OR you can edit `/etc/passwd` file and change/append `/bin/bash` in the line where your user located.

bash: line 10: mix: command not found when building Elixir app with edeliver

Another dummy error which could be fixed in a minute.

$ mix edeliver build release                  

BUILDING RELEASE OF AWESOMEBOT APP ON BUILD HOST

-----> Authorizing hosts
-----> Ensuring hosts are ready to accept git pushes
-----> Pushing new commits with git to: [email protected]


-----> Resetting remote hosts to 568e7c43e372ed947e45e3dfe2a641f5dc771bf4
-----> Cleaning generated files from last build
-----> Fetching / Updating dependencies
using mix to fetch and update deps
bash: line 10: mix: command not found

FAILED 127:

    [ -f ~/.profile ] && source ~/.profile
    set -e
    cd /home/bots/apps/builds
    if [ "mix" = "rebar" ]; then
      echo "using rebar to fetch and update deps"
      ./rebar  update-deps get-deps
    elif [ "mix" = "mix" ]; then
      echo "using mix to fetch and update deps"
      if [ ! -f ~/.mix/rebar ]; then
        APP="awesomebot" MIX_ENV="prod" mix local.rebar
      else
        echo "rebar for mix was built already"
      fi
      APP="awesomebot" MIX_ENV="prod" mix local.hex --force
      APP="awesomebot" MIX_ENV="prod" mix deps.get
    fi

Solution is simple -you need to install `mix`, so follow the instructions here: http://elixir-lang.org/install.html#unix-and-unix-like

Add Erlang Solutions repo: wget https://packages.erlang-solutions.com/erlang-solutions_1.0_all.deb && sudo dpkg -i erlang-solutions_1.0_all.deb
Run: sudo apt-get update
Install the Erlang/OTP platform and all of its applications: sudo apt-get install esl-erlang
Install Elixir: sudo apt-get install elixir

Rails 3 migration fails after MySQL upgrade to 5.7.10

Recently I upgraded MySQL to 5.7.10 and realised that I cannot run new model migrations on my old Rails 3 project anymore:

Mysql2::Error: All parts of a PRIMARY KEY must be NOT NULL; if you need NULL in a key, use UNIQUE instead: CREATE TABLE `bot_users` (`id` int(11) DEFAULT NULL auto_increment PRIMARY KEY, `bot_type` int(11) DEFAULT 1, `user_id` varchar(255), `first_name` varchar(255), `last_name` varchar(255), `username` varchar(255), `created_at` datetime NOT NULL, `updated_at` datetime NOT NULL) 

It appears that MySQL version 5.7 and more doesnt support NULL default anymore so I need a workaround –
create initializer `config/initializers/mysql2_adapter.rb` that has following contents:

class ActiveRecord::ConnectionAdapters::Mysql2Adapter
  NATIVE_DATABASE_TYPES[:primary_key] = "int(11) auto_increment PRIMARY KEY"
end

After that migration runs fine.