From 770207186a8d337d38b714e0b046df363a90b013 Mon Sep 17 00:00:00 2001 From: "b.courtois" Date: Mon, 9 Jun 2025 12:40:44 +0200 Subject: [PATCH 1/2] Do not use require_relative with native extension Replace `require_relative "../llhttp_ext"` by `require "llhttp_ext"` to load the native extension. This improves compatibility with Bundler and RubyGems, especially in environments using `bundle install --standalone` or other setups where the extension may not be located relative to the Ruby file. Using `require` ensures the extension is loaded from the load path, following RubyGems best practices for native extensions. --- ffi/lib/llhttp.rb | 1 + mri/lib/llhttp/parser.rb | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/ffi/lib/llhttp.rb b/ffi/lib/llhttp.rb index 236c81e..329b06c 100644 --- a/ffi/lib/llhttp.rb +++ b/ffi/lib/llhttp.rb @@ -10,6 +10,7 @@ module LLHttp require_relative "llhttp/version" extend FFI::Library + ffi_lib(FFI::Compiler::Loader.find("llhttp-ext")) callback :llhttp_data_cb, [:pointer, :size_t], :void diff --git a/mri/lib/llhttp/parser.rb b/mri/lib/llhttp/parser.rb index 949e4e2..95f82aa 100644 --- a/mri/lib/llhttp/parser.rb +++ b/mri/lib/llhttp/parser.rb @@ -49,4 +49,4 @@ def initialize(delegate, type: :both) end end -require_relative "../llhttp_ext" +require "llhttp_ext" From 989ead646a7db6e0c99ae7433b92c8668ef3fe8c Mon Sep 17 00:00:00 2001 From: "b.courtois" Date: Tue, 24 Jun 2025 22:43:08 +0200 Subject: [PATCH 2/2] Pin io-event to ~> 1.8.0 in test due to compat issue This commit is mostly here to demonstrate the tests are passing with this version of io-event. A refactor of the tests might be required. --- ffi/Gemfile | 4 ++++ mri/Gemfile | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/ffi/Gemfile b/ffi/Gemfile index f80e899..0bbe487 100644 --- a/ffi/Gemfile +++ b/ffi/Gemfile @@ -12,5 +12,9 @@ end group :test do gem "async" gem "io-endpoint" + # io-event 1.9.0 broke the compat with our "fork based test" + # See discussion in https://github.com/bryanp/llhttp/pull/34 + # and https://github.com/socketry/io-event/issues/36 + gem "io-event", "~> 1.8.0" gem "rspec" end diff --git a/mri/Gemfile b/mri/Gemfile index f80e899..0bbe487 100644 --- a/mri/Gemfile +++ b/mri/Gemfile @@ -12,5 +12,9 @@ end group :test do gem "async" gem "io-endpoint" + # io-event 1.9.0 broke the compat with our "fork based test" + # See discussion in https://github.com/bryanp/llhttp/pull/34 + # and https://github.com/socketry/io-event/issues/36 + gem "io-event", "~> 1.8.0" gem "rspec" end