jc00ke / guard-puma

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

Crash if config/puma.rb is missing #38

Closed jodosha closed 5 years ago

jodosha commented 5 years ago

I have a test app without config/puma.rb, and this Guardfile:

guard "puma", port: ENV["HANAMI_PORT"] || 2300 do
  watch(%r{config/*})
  watch(%r{lib/*})
  watch(%r{apps/*})
end

When the app is started, puma crashes because it fails to find config/puma.rb. If I add it, everything works fine.

$ bundle exec guard -n f -i -G Guardfile
12:38:57 - INFO - Using Guardfile at /Users/luca/Code/soundeck/Guardfile.
12:38:57 - INFO - Puma starting on port 2300 in development environment.
12:38:57 - INFO - Guard is now watching at '/Users/luca/Code/soundeck'
Traceback (most recent call last):
    11: from /Users/luca/.gem/ruby/2.6.0/bin/puma:23:in `<main>'
    10: from /Users/luca/.gem/ruby/2.6.0/bin/puma:23:in `load'
     9: from /Users/luca/.gem/ruby/2.6.0/gems/puma-3.12.0/bin/puma:8:in `<top (required)>'
     8: from /Users/luca/.gem/ruby/2.6.0/gems/puma-3.12.0/bin/puma:8:in `new'
     7: from /Users/luca/.gem/ruby/2.6.0/gems/puma-3.12.0/lib/puma/cli.rb:69:in `initialize'
     6: from /Users/luca/.gem/ruby/2.6.0/gems/puma-3.12.0/lib/puma/cli.rb:69:in `new'
     5: from /Users/luca/.gem/ruby/2.6.0/gems/puma-3.12.0/lib/puma/launcher.rb:59:in `initialize'
     4: from /Users/luca/.gem/ruby/2.6.0/gems/puma-3.12.0/lib/puma/configuration.rb:192:in `load'
     3: from /Users/luca/.gem/ruby/2.6.0/gems/puma-3.12.0/lib/puma/configuration.rb:192:in `each'
     2: from /Users/luca/.gem/ruby/2.6.0/gems/puma-3.12.0/lib/puma/configuration.rb:192:in `block in load'
     1: from /Users/luca/.gem/ruby/2.6.0/gems/puma-3.12.0/lib/puma/dsl.rb:41:in `_load_from'
/Users/luca/.gem/ruby/2.6.0/gems/puma-3.12.0/lib/puma/dsl.rb:41:in `read': No such file or directory @ rb_sysopen - --control-token (Errno::ENOENT)
jc00ke commented 5 years ago

Thanks for reporting, @jodosha. I assume I can recreate with a newly generated Hanami app? If so, I'll take a look, but probably won't have time until this weekend.

jodosha commented 5 years ago

@jc00ke A simple Rack app is enough to reproduce the problem. Here's a gist that I prepared for you: https://gist.github.com/jodosha/0f287d613ad753783b787318faf4203d

jc00ke commented 5 years ago

@jodosha can you try out master when you get a chance? ac351d6 should fix the issue.

jodosha commented 5 years ago

@jc00ke It works as expected. Thanks for fixing it 👍

AlexWayfer commented 5 years ago

@jc00ke, excuse me, but I think that DEFAULT_CONFIG_FILE_PATH should be changed instead of fetch with literal default. I mean… now we have two defaults. For what?

jc00ke commented 5 years ago

@AlexWayfer yeah, good point, I should probably reorganize some of that logic.