1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Elixirの環境構築を一発で終わらせる!

Last updated at Posted at 2020-09-25

概要

elixirを始めるにあたって、依存するアプリケーションやerlangのインストール、erlenvexenvを用いたバージョン管理をするのが大変そうだと思ったので対話形式のスクリプトを作ってみました

環境

  • macOS
  • brewはインストール済み
  • anyenvを使うのでない人はスクリプト内で入れる

スクリプト

#!/bin/bash

# brewで必要なファイルを入れる
TARGETS=(
  openssl@1.1
  unixodbc
  wxmac
  fop
)

echo "Install dependencies. If you don't have applications, enter 'y' key."

for target in ${TARGETS[@]}
do
  echo ""
  read -p "Do you want install ${target}? (y/n): " check
  if [ $check = "y" ]; then
      brew install $target
      if [ $target = "openssl@1.1" ]; then
        export PATH="$PATH:/usr/local/opt/openssl@1.1/bin"
        echo 'export PATH="/usr/local/opt/openssl@1.1/bin:$PATH"' >> $HOME/.zshrc # zsh
      fi
  fi
done

# anyenvいれる
if !(type "anyenv" > /dev/null 2>&1); then
  echo -e "\nanyenv is installing..."
  git clone https://github.com/anyenv/anyenv $HOME/.anyenv
  $HOME/.anyenv/bin/anyenv init
  export PATH="$PATH:$HOME/./anyenv/bin"
  anyenv install --init
else
  echo -e "\nanyenv is already setuped."
fi

# erlenv, exenvいれる
arr=(erlenv exenv)

for lang in ${arr[@]}
do
  if !(type "$lang" > /dev/null 2>&1); then
    echo -e "\n${lang} is installing..."
    anyenv install $lang
    export PATH="$PATH:$HOME/./anyenv/envs/${lang}/bin"
  else
    echo -e "\n${lang} is already setuped."
  fi
done

# erlangインストール
echo ""
read -p "Enter erlang version (version or n [ex: 23.1]): " erlang_version

if [ $erlang_version != "n" ]; then
  echo -p "\nDownload from here: http://www.erlang.org/download/otp_src_${erlang_version}.tar.gz"
  curl -OL http://erlang.org/download/otp_src_${erlang_version}.tar.gz > otp_src_${erlang_version}.tar.gz
  # 解凍, インストール
  tar zxf otp_src_${erlang_version}.tar.gz
  cd otp_src_${erlang_version}

  ./configure                                                    \
    --prefix=$HOME/.anyenv/envs/erlenv/releases/$erlang_version  \
    --enable-dynamic-ssl-lib                                     \
    --with-ssl=/usr/local/opt/openssl@1.1                        \
    --enable-smp-support                                         \
    --enable-threads                                             \
    --enable-darwin-64bit                                        \
    --enable-kernel-poll                                         \
    --enable-hipe                                                \
    --without-javac                                              \
    --enable-dirty-schedulers                                    \
    --enable-sharing-preserving                                  \
    --enable-lock-counter                                        \
    --disable-sctp                                               \
    --without-obdc


  make -j 4
  make install

  # global設定
  erlenv global ${erlang_version}
  erlenv rehash

  # 不要なファイル削除
  echo ""
  read -p "remove erlang file? (y/n): " remove_erlang
  if [ $remove_erlang = "y" ]; then
    cd ..
    rm -rf otp_src_${erlang_version} otp_src_${erlang_version}.tar.gz
  fi
fi

# elixerインストール
echo ""
exenv install --list
echo ""
read -p "Choose elixir version (version or n [ex: 1.10.0]): " elixir_version

if [ $elixir_version != "n"]; then
  exenv install ${elixir_version}
  # global設定
  exenv global ${elixir_version}
fi

https://qiita.com/zacky1972/items/27676894a03fb881e160

configureのオプションはあまりわからないのでコチラの記事を参考にさせていただきました

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?