Skip to content

Commit

Permalink
Try to load C extension from the lib directory
Browse files Browse the repository at this point in the history
RubyGems 3.4 removes the contents of `ext/` under installation.
JRuby should look for the extension under `lib/` instead.
  • Loading branch information
hsbt authored and unflxw committed Jan 3, 2023
1 parent c841b6d commit 1443e05
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
bump: "patch"
type: "fix"
---

Attempt to load C extension from lib/ directory. Fixes an issue where JRuby would fail to load
the extension from the ext/ directory, as the directory is cleaned after installation when using
RubyGems 3.4.0.
7 changes: 6 additions & 1 deletion lib/appsignal/extension/jruby.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,12 @@ def self.lib_extension
end

begin
ffi_lib File.join(File.dirname(__FILE__), "../../../ext/libappsignal.#{lib_extension}")
begin
# RubyGems will install the extension in the gem's lib directory.
ffi_lib File.join(File.dirname(__FILE__), "../../../lib/libappsignal.#{lib_extension}")
rescue LoadError
ffi_lib File.join(File.dirname(__FILE__), "../../../ext/libappsignal.#{lib_extension}")
end
typedef AppsignalString.by_value, :appsignal_string

attach_function :appsignal_start, [], :void
Expand Down

0 comments on commit 1443e05

Please sign in to comment.