LoginSignup
2
2

More than 5 years have passed since last update.

Phoenix v0.4.1 のアプリを v0.5.0 にアップグレードした

Last updated at Posted at 2014-10-24

Phoenix v0.4.1 で作ったアプリを v0.5.0 に upgrade したときにやったことをメモする。

Phoenix v0.5.0 を用意

$ cd phoenix
$ git pull
$ git checkout v0.5.0
$ mix do deps.get, compile
...省略
** (Mix) You're trying to run :phoenix on Elixir v1.0.0 but it has declared in its mix.exs file it supports only Elixir ~> 1.0.1 or ~> 1.1

失敗。。エラーメッセージから Elixir 1.0.1 以上が必要とのこと。
exenv 使っているので以下の通り Elixir 1.0.1 を install した。

$ exenv install 1.0.1
$ exenv global 1.0.1

気を取り直して phoenix.app 作り直した。

$ mix do deps.get, compile
...省略
Generated phoenix.app

アプリを v0.5.0 に上げる

Rails でいうところの rake rails:update はないので、アプリ作成コマンドを代用する。
mix phoenix.new で v0.4.1 で作られているアプリを上書きする。とりあえず全て Y 押した。

$ cd phoenix
$ mix phoenix.new my_v0.4.1_app ../my_v0.4.1_app/
* creating ../my_v0.4.1_app/.gitignore
/my_v0.4.1_app/.gitignore already exists, overwrite? [Yn] Y
...以下上書きするファイルを同様に聞かれる

上書きされたファイルの内容をチェックして、直すところは直す。

$ mix do deps.get, compile

v0.5.0 用に実際に直したところ

CHANGELOG を確認するのが手っ取り早い。いくつか breaking change も入っている。

https://github.com/phoenixframework/phoenix/blob/master/CHANGELOG.md

以下実際に直したところ、というか直さないと動かなかったところ。

  • controller に plug :action が必要になった
    • なのでつける
  • default で JSON の alias がなくなった
    • Phoenix が依存している Poison という json library を使う
    • 具体的には alias Poison, as: JSON をつける
  • heroku に上げていたので、elixir_buildpack.config の Elixir version を変更
    • 1.0.0 -> 1.0.1 にした
    • 1.0.0 のままだと plug 周りで以下のコンパイルエラーがでた
== Compilation error on file lib/plug/conn/adapter.ex ==
** (RuntimeError) cannot compile Plug because the :cowboy application is not available. Please ensure it is listed as a dependency before the plug one.
    lib/plug/conn/adapter.ex:4: (file)
    (elixir) src/elixir_lexical.erl:17: :elixir_lexical.run/3
    (elixir) lib/kernel/parallel_compiler.ex:97: anonymous fn/4 in Kernel.ParallelCompiler.spawn_compilers/8

could not compile dependency plug, mix compile failed. You can recompile this dependency with `mix deps.compile plug` or update it with `mix deps.update plug`

ちなみに。。。

v0.5.0 は heroku で動かない。パスの問題があるためなのだけど、このコミットで直っている。v0.5.0 を諦めて master を使ったら動いた。ということで今すぐやるなら master(v0.6.0dev) がおすすめ。

SEE ALSO

2
2
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
2
2