hanami / view

Views, templates and presenters for Ruby web applications
http://hanamirb.org
MIT License
173 stars 80 forks source link

Hanami::View::Rendering::TemplateName: Fix frozen string literal error #166

Closed MITSUBOSHI closed 4 years ago

MITSUBOSHI commented 4 years ago

Problems

It's impossible to run hanami server when using ruby 2.7.0 (the reasons are below)

Causes

Execution Environment

Steps to reproduce the problem

  1. Use ruby 2.7.0
  2. hanami new bookshelf & bundle install
  3. bundle exec hanami server -> then, the issued problem occurs

others

error log ```log Boot Error Something went wrong while loading /Users/mitsubosh/Practice/043_hanami/bookshelf/config.ru FrozenError: can't modify frozen String: "Web::Views::ApplicationLayout" /Users/mitsubosh/Practice/043_hanami/bookshelf/vendor/bundle/ruby/2.7.0/gems/hanami-view-1.3.2/lib/hanami/view/rendering/template_name.rb:45:in `gsub!' /Users/mitsubosh/Practice/043_hanami/bookshelf/vendor/bundle/ruby/2.7.0/gems/hanami-view-1.3.2/lib/hanami/view/rendering/template_name.rb:45:in `replace!' /Users/mitsubosh/Practice/043_hanami/bookshelf/vendor/bundle/ruby/2.7.0/gems/hanami-view-1.3.2/lib/hanami/view/rendering/template_name.rb:30:in `block in compile!' /Users/mitsubosh/Practice/043_hanami/bookshelf/vendor/bundle/ruby/2.7.0/gems/hanami-view-1.3.2/lib/hanami/view/rendering/template_name.rb:38:in `block in tokens' /Users/mitsubosh/Practice/043_hanami/bookshelf/vendor/bundle/ruby/2.7.0/gems/hanami-view-1.3.2/lib/hanami/view/rendering/template_name.rb:37:in `each' /Users/mitsubosh/Practice/043_hanami/bookshelf/vendor/bundle/ruby/2.7.0/gems/hanami-view-1.3.2/lib/hanami/view/rendering/template_name.rb:37:in `tokens' /Users/mitsubosh/Practice/043_hanami/bookshelf/vendor/bundle/ruby/2.7.0/gems/hanami-view-1.3.2/lib/hanami/view/rendering/template_name.rb:30:in `compile!' /Users/mitsubosh/Practice/043_hanami/bookshelf/vendor/bundle/ruby/2.7.0/gems/hanami-view-1.3.2/lib/hanami/view/rendering/template_name.rb:17:in `initialize' /Users/mitsubosh/Practice/043_hanami/bookshelf/vendor/bundle/ruby/2.7.0/gems/hanami-view-1.3.2/lib/hanami/view/dsl.rb:208:in `new' /Users/mitsubosh/Practice/043_hanami/bookshelf/vendor/bundle/ruby/2.7.0/gems/hanami-view-1.3.2/lib/hanami/view/dsl.rb:208:in `template' /Users/mitsubosh/Practice/043_hanami/bookshelf/vendor/bundle/ruby/2.7.0/gems/hanami-view-1.3.2/lib/hanami/layout.rb:82:in `template' /Users/mitsubosh/Practice/043_hanami/bookshelf/vendor/bundle/ruby/2.7.0/gems/hanami-view-1.3.2/lib/hanami/view/rendering/templates_finder.rb:103:in `template_name' /Users/mitsubosh/Practice/043_hanami/bookshelf/vendor/bundle/ruby/2.7.0/gems/hanami-view-1.3.2/lib/hanami/view/rendering/templates_finder.rb:86:in `_find' /Users/mitsubosh/Practice/043_hanami/bookshelf/vendor/bundle/ruby/2.7.0/gems/hanami-view-1.3.2/lib/hanami/view/rendering/templates_finder.rb:72:in `find' /Users/mitsubosh/Practice/043_hanami/bookshelf/vendor/bundle/ruby/2.7.0/gems/hanami-view-1.3.2/lib/hanami/view/rendering/layout_registry.rb:58:in `templates' /Users/mitsubosh/Practice/043_hanami/bookshelf/vendor/bundle/ruby/2.7.0/gems/hanami-view-1.3.2/lib/hanami/view/rendering/layout_registry.rb:49:in `prepare!' /Users/mitsubosh/Practice/043_hanami/bookshelf/vendor/bundle/ruby/2.7.0/gems/hanami-view-1.3.2/lib/hanami/view/rendering/layout_registry.rb:24:in `initialize' /Users/mitsubosh/Practice/043_hanami/bookshelf/vendor/bundle/ruby/2.7.0/gems/hanami-view-1.3.2/lib/hanami/layout.rb:62:in `new' /Users/mitsubosh/Practice/043_hanami/bookshelf/vendor/bundle/ruby/2.7.0/gems/hanami-view-1.3.2/lib/hanami/layout.rb:62:in `registry' /Users/mitsubosh/Practice/043_hanami/bookshelf/vendor/bundle/ruby/2.7.0/gems/hanami-view-1.3.2/lib/hanami/layout.rb:114:in `load_registry!' /Users/mitsubosh/Practice/043_hanami/bookshelf/vendor/bundle/ruby/2.7.0/gems/hanami-view-1.3.2/lib/hanami/layout.rb:105:in `load!' /Users/mitsubosh/Practice/043_hanami/bookshelf/vendor/bundle/ruby/2.7.0/gems/hanami-view-1.3.2/lib/hanami/view/configuration.rb:422:in `block in load!' /Users/mitsubosh/.rbenv/versions/2.7.0/lib/ruby/2.7.0/set.rb:328:in `each_key' /Users/mitsubosh/.rbenv/versions/2.7.0/lib/ruby/2.7.0/set.rb:328:in `each' /Users/mitsubosh/Practice/043_hanami/bookshelf/vendor/bundle/ruby/2.7.0/gems/hanami-view-1.3.2/lib/hanami/view/configuration.rb:422:in `load!' /Users/mitsubosh/Practice/043_hanami/bookshelf/vendor/bundle/ruby/2.7.0/gems/hanami-view-1.3.2/lib/hanami/view.rb:264:in `load!' (eval):1:in `block (2 levels) in ' /Users/mitsubosh/Practice/043_hanami/bookshelf/vendor/bundle/ruby/2.7.0/gems/hanami-1.3.3/lib/hanami/components/components.rb:474:in `module_eval' /Users/mitsubosh/Practice/043_hanami/bookshelf/vendor/bundle/ruby/2.7.0/gems/hanami-1.3.3/lib/hanami/components/components.rb:474:in `block (2 levels) in ' /Users/mitsubosh/Practice/043_hanami/bookshelf/vendor/bundle/ruby/2.7.0/gems/hanami-1.3.3/lib/hanami/components/component.rb:40:in `call' /Users/mitsubosh/Practice/043_hanami/bookshelf/vendor/bundle/ruby/2.7.0/gems/hanami-1.3.3/lib/hanami/components/components.rb:362:in `block (3 levels) in ' /Users/mitsubosh/Practice/043_hanami/bookshelf/vendor/bundle/ruby/2.7.0/gems/hanami-1.3.3/lib/hanami/components/components.rb:361:in `each' /Users/mitsubosh/Practice/043_hanami/bookshelf/vendor/bundle/ruby/2.7.0/gems/hanami-1.3.3/lib/hanami/components/components.rb:361:in `block (2 levels) in ' /Users/mitsubosh/Practice/043_hanami/bookshelf/vendor/bundle/ruby/2.7.0/gems/hanami-1.3.3/lib/hanami/components/component.rb:40:in `call' /Users/mitsubosh/Practice/043_hanami/bookshelf/vendor/bundle/ruby/2.7.0/gems/hanami-1.3.3/lib/hanami/components/components.rb:278:in `block (3 levels) in ' /Users/mitsubosh/Practice/043_hanami/bookshelf/vendor/bundle/ruby/2.7.0/gems/hanami-1.3.3/lib/hanami/configuration.rb:144:in `block in apps' /Users/mitsubosh/Practice/043_hanami/bookshelf/vendor/bundle/ruby/2.7.0/gems/hanami-1.3.3/lib/hanami/configuration.rb:143:in `each_pair' /Users/mitsubosh/Practice/043_hanami/bookshelf/vendor/bundle/ruby/2.7.0/gems/hanami-1.3.3/lib/hanami/configuration.rb:143:in `apps' /Users/mitsubosh/Practice/043_hanami/bookshelf/vendor/bundle/ruby/2.7.0/gems/hanami-1.3.3/lib/hanami/components/components.rb:277:in `block (2 levels) in ' /Users/mitsubosh/Practice/043_hanami/bookshelf/vendor/bundle/ruby/2.7.0/gems/hanami-1.3.3/lib/hanami/components/component.rb:44:in `call' /Users/mitsubosh/Practice/043_hanami/bookshelf/vendor/bundle/ruby/2.7.0/gems/hanami-1.3.3/lib/hanami/components.rb:108:in `block (2 levels) in resolve' /Users/mitsubosh/Practice/043_hanami/bookshelf/vendor/bundle/ruby/2.7.0/gems/concurrent-ruby-1.1.5/lib/concurrent/map.rb:193:in `block in fetch_or_store' /Users/mitsubosh/Practice/043_hanami/bookshelf/vendor/bundle/ruby/2.7.0/gems/concurrent-ruby-1.1.5/lib/concurrent/map.rb:172:in `fetch' /Users/mitsubosh/Practice/043_hanami/bookshelf/vendor/bundle/ruby/2.7.0/gems/concurrent-ruby-1.1.5/lib/concurrent/map.rb:192:in `fetch_or_store' /Users/mitsubosh/Practice/043_hanami/bookshelf/vendor/bundle/ruby/2.7.0/gems/hanami-1.3.3/lib/hanami/components.rb:106:in `block in resolve' /Users/mitsubosh/Practice/043_hanami/bookshelf/vendor/bundle/ruby/2.7.0/gems/hanami-1.3.3/lib/hanami/components.rb:105:in `each' /Users/mitsubosh/Practice/043_hanami/bookshelf/vendor/bundle/ruby/2.7.0/gems/hanami-1.3.3/lib/hanami/components.rb:105:in `resolve' /Users/mitsubosh/Practice/043_hanami/bookshelf/vendor/bundle/ruby/2.7.0/gems/hanami-1.3.3/lib/hanami/components/component.rb:144:in `resolve_requirements' /Users/mitsubosh/Practice/043_hanami/bookshelf/vendor/bundle/ruby/2.7.0/gems/hanami-1.3.3/lib/hanami/components/component.rb:36:in `call' /Users/mitsubosh/Practice/043_hanami/bookshelf/vendor/bundle/ruby/2.7.0/gems/hanami-1.3.3/lib/hanami/components.rb:108:in `block (2 levels) in resolve' /Users/mitsubosh/Practice/043_hanami/bookshelf/vendor/bundle/ruby/2.7.0/gems/concurrent-ruby-1.1.5/lib/concurrent/map.rb:193:in `block in fetch_or_store' /Users/mitsubosh/Practice/043_hanami/bookshelf/vendor/bundle/ruby/2.7.0/gems/concurrent-ruby-1.1.5/lib/concurrent/map.rb:172:in `fetch' /Users/mitsubosh/Practice/043_hanami/bookshelf/vendor/bundle/ruby/2.7.0/gems/concurrent-ruby-1.1.5/lib/concurrent/map.rb:192:in `fetch_or_store' /Users/mitsubosh/Practice/043_hanami/bookshelf/vendor/bundle/ruby/2.7.0/gems/hanami-1.3.3/lib/hanami/components.rb:106:in `block in resolve' /Users/mitsubosh/Practice/043_hanami/bookshelf/vendor/bundle/ruby/2.7.0/gems/hanami-1.3.3/lib/hanami/components.rb:105:in `each' /Users/mitsubosh/Practice/043_hanami/bookshelf/vendor/bundle/ruby/2.7.0/gems/hanami-1.3.3/lib/hanami/components.rb:105:in `resolve' /Users/mitsubosh/Practice/043_hanami/bookshelf/vendor/bundle/ruby/2.7.0/gems/hanami-1.3.3/lib/hanami.rb:126:in `boot' /Users/mitsubosh/Practice/043_hanami/bookshelf/vendor/bundle/ruby/2.7.0/gems/hanami-1.3.3/lib/hanami.rb:151:in `app' /Users/mitsubosh/Practice/043_hanami/bookshelf/config.ru:3:in `block in inner_app' /Users/mitsubosh/Practice/043_hanami/bookshelf/vendor/bundle/ruby/2.7.0/gems/rack-2.0.8/lib/rack/builder.rb:55:in `instance_eval' /Users/mitsubosh/Practice/043_hanami/bookshelf/vendor/bundle/ruby/2.7.0/gems/rack-2.0.8/lib/rack/builder.rb:55:in `initialize' /Users/mitsubosh/Practice/043_hanami/bookshelf/config.ru:1:in `new' /Users/mitsubosh/Practice/043_hanami/bookshelf/config.ru:1:in `inner_app' /Users/mitsubosh/Practice/043_hanami/bookshelf/vendor/bundle/ruby/2.7.0/gems/shotgun-0.9.2/lib/shotgun/loader.rb:113:in `eval' /Users/mitsubosh/Practice/043_hanami/bookshelf/vendor/bundle/ruby/2.7.0/gems/shotgun-0.9.2/lib/shotgun/loader.rb:113:in `inner_app' /Users/mitsubosh/Practice/043_hanami/bookshelf/vendor/bundle/ruby/2.7.0/gems/shotgun-0.9.2/lib/shotgun/loader.rb:103:in `assemble_app' /Users/mitsubosh/Practice/043_hanami/bookshelf/vendor/bundle/ruby/2.7.0/gems/shotgun-0.9.2/lib/shotgun/loader.rb:86:in `proceed_as_child' /Users/mitsubosh/Practice/043_hanami/bookshelf/vendor/bundle/ruby/2.7.0/gems/shotgun-0.9.2/lib/shotgun/loader.rb:31:in `call!' /Users/mitsubosh/Practice/043_hanami/bookshelf/vendor/bundle/ruby/2.7.0/gems/shotgun-0.9.2/lib/shotgun/loader.rb:18:in `call' /Users/mitsubosh/Practice/043_hanami/bookshelf/vendor/bundle/ruby/2.7.0/gems/hanami-1.3.3/lib/hanami/assets/static.rb:49:in `call' /Users/mitsubosh/Practice/043_hanami/bookshelf/vendor/bundle/ruby/2.7.0/gems/rack-2.0.8/lib/rack/lint.rb:49:in `_call' /Users/mitsubosh/Practice/043_hanami/bookshelf/vendor/bundle/ruby/2.7.0/gems/rack-2.0.8/lib/rack/lint.rb:37:in `call' /Users/mitsubosh/Practice/043_hanami/bookshelf/vendor/bundle/ruby/2.7.0/gems/rack-2.0.8/lib/rack/show_exceptions.rb:23:in `call' /Users/mitsubosh/Practice/043_hanami/bookshelf/vendor/bundle/ruby/2.7.0/gems/rack-2.0.8/lib/rack/handler/webrick.rb:86:in `service' /Users/mitsubosh/.rbenv/versions/2.7.0/lib/ruby/2.7.0/webrick/httpserver.rb:140:in `service' /Users/mitsubosh/.rbenv/versions/2.7.0/lib/ruby/2.7.0/webrick/httpserver.rb:96:in `run' /Users/mitsubosh/.rbenv/versions/2.7.0/lib/ruby/2.7.0/webrick/server.rb:307:in `block in start_thread' ```
jodosha commented 4 years ago

@MITSUBOSHI Thanks for this pull request. I'm taking care of this right now. You'll hear soon from me when I'll release a new version of hanami-view.

jodosha commented 4 years ago

@MITSUBOSHI would you please rebase master with this branch? In this way flaky specs and Travis CI problems won't affect the build of this PR. Thanks.

MITSUBOSHI commented 4 years ago

@jodosha I rebased it and CI passed :)