Help us understand the problem. What is going on with this article?

Hanamiをコマンドどおりに実行したらエラーになった件について

More than 1 year has passed since last update.

はじめに

Ruby界隈で話題になっているHanamiというフレームワーク。ヨッシャイクゾ!wと思ってまずはやってみた。

コマンドを叩いてみると...

$ gem install hanami
$ hanami new app
$ bundle install

fmfm。こりゃRailsのおまじないとおんなじ感じでいけそうやん。あとはrails s よろしく hanami s やなと思って叩いてみたところ...

$ bundle exec hanami server
wrong number of arguments (given 1, expected 2)
/Users/user/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/dotenv-2.3.0/lib/dotenv/parser.rb:33:in `call'
    /Users/user/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/hanami-1.2.0/lib/hanami/env.rb:59:in `load!'
    /Users/user/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/hanami-1.2.0/lib/hanami/environment.rb:493:in `set_application_env_vars!'
    /Users/user/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/hanami-1.2.0/lib/hanami/environment.rb:475:in `set_env_vars!'
    /Users/user/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/hanami-1.2.0/lib/hanami/environment.rb:197:in `block in initialize'
    /Users/user/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/hanami-1.2.0/lib/hanami/environment.rb:197:in `synchronize'
    /Users/user/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/hanami-1.2.0/lib/hanami/environment.rb:197:in `initialize'
    /Users/user/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/hanami-1.2.0/lib/hanami/cli/commands/command.rb:76:in `new'
    /Users/user/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/hanami-1.2.0/lib/hanami/cli/commands/command.rb:76:in `call'
    /Users/user/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/hanami-cli-0.2.0/lib/hanami/cli.rb:57:in `call'
    /Users/user/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/hanami-1.2.0/bin/hanami:6:in `<top (required)>'
    /Users/user/.rbenv/versions/2.5.0/bin/hanami:23:in `load'
    /Users/user/.rbenv/versions/2.5.0/bin/hanami:23:in `<top (required)>'
    /Users/user/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/bundler-1.16.1/lib/bundler/cli/exec.rb:75:in `load'
    /Users/user/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/bundler-1.16.1/lib/bundler/cli/exec.rb:75:in `kernel_load'
    /Users/user/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/bundler-1.16.1/lib/bundler/cli/exec.rb:28:in `run'
    /Users/user/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/bundler-1.16.1/lib/bundler/cli.rb:424:in `exec'
    /Users/user/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/bundler-1.16.1/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
    /Users/user/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/bundler-1.16.1/lib/bundler/vendor/thor/lib/thor/invocation.rb:126:in `invoke_command'
    /Users/user/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/bundler-1.16.1/lib/bundler/vendor/thor/lib/thor.rb:387:in `dispatch'
    /Users/user/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/bundler-1.16.1/lib/bundler/cli.rb:27:in `dispatch'
    /Users/user/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/bundler-1.16.1/lib/bundler/vendor/thor/lib/thor/base.rb:466:in `start'
    /Users/user/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/bundler-1.16.1/lib/bundler/cli.rb:18:in `start'
    /Users/user/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/bundler-1.16.1/exe/bundle:30:in `block in <top (required)>'
    /Users/user/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/bundler-1.16.1/lib/bundler/friendly_errors.rb:122:in `with_friendly_errors'
    /Users/user/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/bundler-1.16.1/exe/bundle:22:in `<top (required)>'
    /Users/user/.rbenv/versions/2.5.0/bin/bundle:23:in `load'
    /Users/user/.rbenv/versions/2.5.0/bin/bundle:23:in `<main>'

ファッ!!?

解決策

Hanamiのコミュニティにて、dotenv というgemのバージョン指定がよくない模様。たしかに/dotenv/parser.rbが悪さしているっぽい。
hanami/chat

Gemfileのdotenv指定を2.2.2に変更する

Gemfile
group :test, :development do
  gem 'dotenv', '~> 2.2.2'
end

からの、起動!

$ bundle exec hanami server
[2018-04-23 21:03:04] INFO  WEBrick 1.4.2
[2018-04-23 21:03:04] INFO  ruby 2.5.0 (2017-12-25) [x86_64-darwin16]
[2018-04-23 21:03:04] INFO  WEBrick::HTTPServer#start: pid=10757 port=2300

http://localhost:2300

スクリーンショット 2018-04-23 21.03.49.png

はろーわーるど!!!

おわりに

いろいろサイト巡って質問してみたんだけど、出始めのフレームワークなのでまずはjoinしている人が多いコミュニティの意見をいろいろ覗いてみるといいのかもしれません。

あと、2018/4/23時点なのでわりとすぐ直ってそうです。

追記(2018/04/30)

gemが修正されたようなので、おそらくすんなり動くと思います!!!
スクリーンショット 2018-04-30 23.16.00.png

参照

Hanami(旧:Lotus) - MicroservicesのためのRubyフレームワーク

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away