jc00ke / guard-puma

Restart puma when files change
MIT License
50 stars 19 forks source link

Default Puma config location in Rails 5.2 crashes on start #36

Closed matoakley closed 5 years ago

matoakley commented 6 years ago

Rails 5.2 includes Puma by default and creates a config files at config/puma.rb. Running this plugin without specifying path to that file results in an error with the following stacktrace:

11: from /usr/local/opt/rbenv/versions/2.5.0/bin/puma:23:in `<main>'
        10: from /usr/local/opt/rbenv/versions/2.5.0/bin/puma:23:in `load'
         9: from /usr/local/Cellar/rbenv/1.0.0/versions/2.5.0/lib/ruby/gems/2.5.0/gems/puma-3.11.4/bin/puma:8:in `<top (required)>'
         8: from /usr/local/Cellar/rbenv/1.0.0/versions/2.5.0/lib/ruby/gems/2.5.0/gems/puma-3.11.4/bin/puma:8:in `new'
         7: from /usr/local/Cellar/rbenv/1.0.0/versions/2.5.0/lib/ruby/gems/2.5.0/gems/puma-3.11.4/lib/puma/cli.rb:69:in `initialize'
         6: from /usr/local/Cellar/rbenv/1.0.0/versions/2.5.0/lib/ruby/gems/2.5.0/gems/puma-3.11.4/lib/puma/cli.rb:69:in `new'
         5: from /usr/local/Cellar/rbenv/1.0.0/versions/2.5.0/lib/ruby/gems/2.5.0/gems/puma-3.11.4/lib/puma/launcher.rb:59:in `initialize'
         4: from /usr/local/Cellar/rbenv/1.0.0/versions/2.5.0/lib/ruby/gems/2.5.0/gems/puma-3.11.4/lib/puma/configuration.rb:192:in `load'
         3: from /usr/local/Cellar/rbenv/1.0.0/versions/2.5.0/lib/ruby/gems/2.5.0/gems/puma-3.11.4/lib/puma/configuration.rb:192:in `each'
         2: from /usr/local/Cellar/rbenv/1.0.0/versions/2.5.0/lib/ruby/gems/2.5.0/gems/puma-3.11.4/lib/puma/configuration.rb:192:in `block in load'
         1: from /usr/local/Cellar/rbenv/1.0.0/versions/2.5.0/lib/ruby/gems/2.5.0/gems/puma-3.11.4/lib/puma/dsl.rb:41:in `_load_from'
/usr/local/Cellar/rbenv/1.0.0/versions/2.5.0/lib/ruby/gems/2.5.0/gems/puma-3.11.4/lib/puma/dsl.rb:41:in `read': No such file or directory @ rb_sysopen - --control-token (Errno::ENOENT)

This can be resolved in the short-term by specifying the path to the default config file in Guardfile e.g.

guard 'puma', config: 'config/puma.rb' do
  watch('Gemfile.lock')
  watch(%r{^config|lib|api/.*})
end

I guess the default path within the plugin may need updating.

AlexWayfer commented 6 years ago

Flame framework uses the same path.

jc00ke commented 6 years ago

Thanks for reporting this, and I apologize for the slow response.

Can you whip up a simple Rails app that I can use to debug? Barebones, no db, no extras if possible.

I'm guessing that this guard is mostly used in Rails projects, but I don't want to make the defaults specific to Rails. Adjusting the Guardfile seems like a decent approach.

ianks commented 5 years ago

This also happens with hanami

jc00ke commented 5 years ago

@ianks do you have an app I could clone that exhibits this behavior?

ianks commented 5 years ago

https://gist.github.com/ianks/35320afd6fcce995fe793edef09372de

jc00ke commented 5 years ago

Can you all give #37 a try? After thinking about it a bit, I'm OK with using config/puma.rb if it exists but still allowing another config file to be set. Thanks, and sorry it took so long to address this. Thanks for documenting the workaround for other users.