LoginSignup
6
4

More than 5 years have passed since last update.

Elixir/Phoenix 初級はじめの一歩 実践(1)

Last updated at Posted at 2019-03-29

ArcSoft_画像243.PNG

はじめに

Phoenixの理解を得るために書籍を購入して動かしています。書籍はやや古いバージョンを基にしているので最新版とで食い違いがあるようです。躓いたところ、教わったことを書き記します。

環境

WSL Ubuntu 18.04

第5章 Hello、world!

p35 mixのサブコマンド phoenix.newとあるのは Phoenix ver1.4では phx.newです。

p36の modest_greeterの生成は phx.new と読み替えないといけません。

ハング

例題のmodest_greeter に限らないのですが私のWSL Ubuntuの環境では依存性のチェックのところでハングします。ctrl+cで強制終了して、2度ほどやり直したら動作しました。他の人の記事でもこの依存性のチェックのところはどうも、トラブルが多い箇所のようです。

Fetch and install dependencies? [Yn] y
* running mix deps.get

ここで固まってしまいます。

Node.jsが厄介

p10のUbuntuの場合のNode.jsのインストール方法に従ったのですが、どうもこれだと古いバージョンになってしまうようです。mix phx.server で起動するとエラーが発生します。

[error] Could not start node watcher because script "/mnt/c/work/elixir/modest_greeter/assets/node_modules
/webpack/bin/webpack.js" does not exist. Your Phoenix application is still running, however assets won't b
e compiled. You may fix this by running "cd assets && npm install"

下記の記事を参考に再インストールしました。
https://qiita.com/seibe/items/36cef7df85fe2cefa3ea

これでもまだエラーができました。
そこで下記の記事をもとにやってみたところ動作するようになりました。
https://qiita.com/kerupani129/items/60ee8c8becc2fe9f0d28

どうも、Node.jsのインストールは厄介な代物のようです。

inotify-tools

さらに次のエラーが出ました。

[error] `inotify-tools` is needed to run `file_system` for your system, check https://github.com/rvoicilas 
/inotify-tools/wiki for more information about how to install it. If it's already installed but not be fou
nd, appoint executable file with `config.exs` or `FILESYSTEM_FSIN・・・

教えてもらったところ、inotify-toolsがインストールされていないからだそうです。このツールはElixirソースが書き直されたときに自動的にreloadするために必要なものだそうです。

下記の記事の通りにインストールしたら動作するようになりました。
https://qiita.com/stc1988/items/464410382f8425681c20

成功

やっと動作するようになりました。 mix phx.server で起動し、ブラウザでアクセスすると無事に表示されました。

2019-03-29_17-37-17.png

謝辞

fukuoka.exの人たちにTwitter上でお世話になっております。ありがとうございます。

6
4
2

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
6
4