LoginSignup
0
0

More than 1 year has passed since last update.

Railsのbinding.irbで処理を止めて変数に代入しようとするとArgumentErrorがでる

Last updated at Posted at 2022-04-12

エラーの説明

動作などを確認する際にbinding.irbで処理を止めて変数に値を代入するような処理を行うと
このようなエラーが表示される。
エラーが表示されても変数の代入は行われるし、
binding.irbで処理を止めない場合も問題なく処理は行われる。
なお、binding.irbを記載する箇所、変数や値はどれでもエラーが出るので関係ない模様。

irb:001:0> a = 1
/Users/ユーザーネーム/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/hirb-0.7.3/lib/hirb/view.rb:186:in `output_value': wrong number of arguments (given 1, expected 0) (ArgumentError)                                                    
        from <internal:prelude>:5:in `irb'                                                   
        from /Users/ユーザーネーム/workspace/runteq/cook_cost/app/controllers/recipes_controller.rb:9:in `index'
        from /Users/ユーザーネーム/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/actionpack-6.1.4.6/lib/action_controller/metal/basic_implicit_render.rb:6:in `send_action'                                                               
        from /Users/ユーザーネーム/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/actionpack-6.1.4.6/lib/abstract_controller/base.rb:228:in `process_action'                                                                               
        from /Users/ユーザーネーム/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/actionpack-6.1.4.6/lib/action_controller/metal/rendering.rb:30:in `process_action'                                                                       
        from /Users/ユーザーネーム/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/actionpack-6.1.4.6/lib/abstract_controller/callbacks.rb:42:in `block in process_action'                                                                  in `process_action'
        from /Users/ユーザーネーム/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/actionpack-6.1.4.6/lib/action_controller/metal/instrumentation.rb:34:in `block in process_action'
        from /Users/ユーザーネーム/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/activesupport-6.1.4.6/lib/active_support/notifications.rb:203:in `block in instrument'
        ... 63 levels...
irb:002:0> a
=> 1

バージョンなど

Ruby 3.1.0
Rails 6.1.4.6
hirb 0.7.3

原因

ログに記載がある通り、hirbが原因の模様。
詳しい原因を調べてみたが、見つからなかった。

対処法

Gemfileから下記を削除。

gem 'hirb'
#あれば削除
gem 'hirb-unicode-steakknife'

bundle installを実行。

まとめ

エラーが表示されてしまうものの、処理は問題なく実行されているので、
gemを削除する必要はないのかもしれない。

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