brianmaierjr / long-haul

A minimal, type-focused Jekyll theme.
http://brianmaierjr.com/long-haul
MIT License
674 stars 776 forks source link

`jekyll serve --livereload` breaks with "undefined method `<<' for #<Http::NativeParser" #108

Open maiamcc opened 2 years ago

maiamcc commented 2 years ago

Neat theme! Had some trouble getting it working on my site. Here's the issue as replicated in this repo, with no changes except adding webrick so Jekyll can actually serve[^1]. (I tried to get up and running with gulp like the readme recommends, but I ran into the same issue as #104 so I then started trying to serve directly with Jekyll commands.)

Software versions

Repro steps

I can open the site at localhost:4000 fine, but when I try to navigate to another page of the site, jekyll serve breaks with the following:

$ bundle exec jekyll serve --livereload --trace
Configuration file: /Users/maiamccormick/code/long-haul/_config.yml
            Source: /Users/maiamccormick/code/long-haul
       Destination: /Users/maiamccormick/code/long-haul/_site
 Incremental build: disabled. Enable with --incremental
      Generating...
                    done in 1.183 seconds.
 Auto-regeneration: enabled for '/Users/maiamccormick/code/long-haul'
LiveReload address: http://127.0.0.1:35729
    Server address: http://127.0.0.1:4000
  Server running... press ctrl-c to stop.
LiveReload experienced an error. Run with --trace for more information.
LiveReload experienced an error. Run with --trace for more information.
#<Thread:0x00007fc777572df8 /Users/maiamccormick/code/long-haul/_vendor/ruby/3.0.0/gems/jekyll-4.2.2/lib/jekyll/commands/serve/live_reload_reactor.rb:41 run> terminated with exception (report_on_exception is true):
/Users/maiamccormick/code/long-haul/_vendor/ruby/3.0.0/gems/jekyll-4.2.2/lib/jekyll/commands/serve/websockets.rb:44:in `dispatch': undefined method `<<' for #<Http::NativeParser:0x00007fc777253898 @method=nil, @path=nil, @version=nil, @headers={}, @body=nil, @state=:request_line, @options={:max_header_length=>10240, :max_headers=>100, :min_tempfile_size=>1048576, :tempfile_class=>Tempfile}> (NoMethodError)
    from /Users/maiamccormick/code/long-haul/_vendor/ruby/3.0.0/gems/em-websocket-0.5.3/lib/em-websocket/connection.rb:79:in `receive_data'
    from /Users/maiamccormick/code/long-haul/_vendor/ruby/3.0.0/gems/eventmachine-1.2.7/lib/eventmachine.rb:195:in `run_machine'
    from /Users/maiamccormick/code/long-haul/_vendor/ruby/3.0.0/gems/eventmachine-1.2.7/lib/eventmachine.rb:195:in `run'
    from /Users/maiamccormick/code/long-haul/_vendor/ruby/3.0.0/gems/jekyll-4.2.2/lib/jekyll/commands/serve/live_reload_reactor.rb:44:in `block in start'
bundler: failed to load command: jekyll (/Users/maiamccormick/code/long-haul/_vendor/ruby/3.0.0/bin/jekyll)
/Users/maiamccormick/code/long-haul/_vendor/ruby/3.0.0/gems/jekyll-4.2.2/lib/jekyll/commands/serve/websockets.rb:44:in `dispatch': undefined method `<<' for #<Http::NativeParser:0x00007fc777253898 @method=nil, @path=nil, @version=nil, @headers={}, @body=nil, @state=:request_line, @options={:max_header_length=>10240, :max_headers=>100, :min_tempfile_size=>1048576, :tempfile_class=>Tempfile}> (NoMethodError)
    from /Users/maiamccormick/code/long-haul/_vendor/ruby/3.0.0/gems/em-websocket-0.5.3/lib/em-websocket/connection.rb:79:in `receive_data'
    from /Users/maiamccormick/code/long-haul/_vendor/ruby/3.0.0/gems/eventmachine-1.2.7/lib/eventmachine.rb:195:in `run_machine'
    from /Users/maiamccormick/code/long-haul/_vendor/ruby/3.0.0/gems/eventmachine-1.2.7/lib/eventmachine.rb:195:in `run'
    from /Users/maiamccormick/code/long-haul/_vendor/ruby/3.0.0/gems/jekyll-4.2.2/lib/jekyll/commands/serve/live_reload_reactor.rb:44:in `block in start'

I've got no idea what's going on here, and livereload (or equivalent) is pretty crucial to my workflow. Thoughts?

[^1]: as per the Jekyll quickstart guide, you need to install webrick for jekyll serve to work with Ruby 3+

maiamcc commented 2 years ago

No idea if it's relevant (as I said, I'm not a ruby person) but the diff to my Gemfile.lock after all the installations above:

Screen Shot 2022-09-29 at 11 34 04 PM
brianmaierjr commented 1 year ago

Working on fixing this! Sorry about the late reply.

brianmaierjr commented 1 year ago

@maiamcc I am having no luck with this issue. I previously used Gulp and Browsersync to do the live reloading but I've since removed that. Unfortunately, your problem persists. I will keep looking but wanted to give an update.

maiamcc commented 1 year ago

Thanks for looking into it, much appreciated!

yabozdar commented 1 year ago

Livereload doesn't break anymore. Check the pull request.

maiamcc commented 1 year ago

Hm I just pulled the latest master and livereload... just seems to work now, even without #123? So uh, thanks!

brianmaierjr commented 1 year ago

Well that's interesting. I'll take a look tomorrow! I have been quite busy so thanks for checking this out @maiamcc and thanks again for your pr @iambozdar