LoginSignup
22
23

More than 5 years have passed since last update.

Windows 8.1にElixirを導入するメモ

Last updated at Posted at 2015-05-19

目的

  • Windows 8.1 + Cmd.exe で iex を叩けて Elixir に触れられる環境を整える
  • ついでにPhoenixも入れておく
  • Windows利用者にも布教しやすいやり方を覚える

流れ

  1. Chocolateyを入れる
  2. cinst nodejs, cinst npm, cinst elixir, cinst erlang
  3. mix で phoenix 入れる
  4. 環境変数パスを通す

こまかーい流れ

1. Chocolateryを入れる

コマンドプロンプト(管理者)を開いて下記を投げ込む

コマンドプロンプト
C:\> @powershell -NoProfile -ExecutionPolicy Bypass -Command "iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))" && SET PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin

環境変数が追加されるので、一旦再起動する。

コマンドプロンプト
C:\> choco help

でいろいろ出てくるようになれば、次のステップへ。

2.cinst nodejs, cinst npm, cinst elixir, cinst erlang

そのまま。順に投げる

コマンドプロンプト
c:\> cinst nodejs
<中略>
c:\> cinst npm
<中略>
c:\> cinst elixir
<中略>
c:\> cinst erlang
<中略>

エラーっぽいのがでてなければおっけー。

※事前にnodejs, npmが導入済みの場合は、choco update nodejs, choco update npm で、最新バージョンにしておきましょう。下記のようなエラーにハマる場合があります。
最後のmix phoenix.server で次のエラーが出てしまいます。

Net.js:157
   this._handle.open(options.fd);
                ^
rror: EINVAL, invalid argument
 at new Socket (net.js:157:18)
 at process.stdin (node.js:687:19)
 at bindWatcherEvents (c:\Users\Tsutomu\work\elixir-stuff\hello_phoenix\node_mo
ules\brunch\lib\watch.js:597:12)
 at c:\Users\Tsutomu\work\elixir-stuff\hello_phoenix\node_modules\brunch\lib\watch.js:667:9
 at c:\Users\Tsutomu\work\elixir-stuff\hello_phoenix\node_modules\brunch\lib\watch.js:557:16
 at c:\Users\Tsutomu\work\elixir-stuff\hello_phoenix\node_modules\brunch\lib\watch.js:188:12
 at c:\Users\Tsutomu\work\elixir-stuff\hello_phoenix\node_modules\brunch\node_modules\async-each\index.js:24:44
 at c:\Users\Tsutomu\work\elixir-stuff\hello_phoenix\node_modules\brunch\lib\watch.js:175:14
 at Object.cb [as oncomplete] (fs.js:169:19)

どうしても nodejs のバージョンをあげたくない!という人は、あとで紹介する mix phoenix.new 時に --no-brunch をつけると nodejs への依存がなくなり、エラーもでなくなります。

3. 環境変数パスを通す

システム→システム詳細設定→環境変数→PATHを選んで編集
C:\Program Files\erl6.4\bin;C:\tools\Elixir\bin を追加する。

なぜelixir がc:\tools にセットアップされたのかは、眠くて覚えていない。。
まぁProgram filesかどっかにはいるので、そのパスを通せばいいと思うよ!

Elixir できあがりの確認

環境変数の反映の為に、コマンドプロンプトをあげなおして

c:\> iex
Interactive Elixir (1.0.4) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)> 1+1
2
iex(2)>

Elixirはここで導入完了です。つぎはPhoenixを入れていきます。

3. mix で phoenix 入れる

Phoenix - Up And Running
ここを見ながら進めればおk。引き続き管理者コマンドプロンプトで進める

コマンドプロンプト
c:\> mix local.hex
c:\> mix archive.install https://github.com/phoenixframework/phoenix/releases/download/v0.13.1/phoenix_new-0.13.1.ez

hello_phoenixの為の環境づくり&サーバー起動

コマンドプロンプト
c:\> mix phoenix.new %userprofile%\work\elixir-stuff\hello_phoenix
Fetch and install dependencies? [Yn] y
* running npm install
* running mix deps.get
<中略>
c:\> cd %userprofile%\work\elixir-stuff\hello_phoenix
c:\> mix phoenix.server

これで、localhost:4000 にアクセスしてなんかみえれば導入完了。お疲れ様でした。
途中、ファイアウォール開けるか聞かれたりするので、適当にYesとしておいてください。

参考リンク

というかむしろこれが本体に近い・・・
chocolatey - Let's get Chocolatey!
elixir - Installing Elixir
2行でWindowsにElixirをインストールするたった一つの冴えているようなやり方
Phoenix Framework(v0.13) 概要

22
23
6

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
22
23