# HG changeset patch
# User Stan Hu <stanhu@gmail.com>
# Date 1718844212 25200
#      Wed Jun 19 17:43:32 2024 -0700
# Node ID af79eb0d57fbec7dcda6af21e10106a49b01c6e1
# Parent  9e444ffe83b1fc73763c3dc10cfc89d32ded9f53
Force ffi gem to use Ruby platform gem

ffi v1.17.0 started shipping precompiled native gems for x86 and
aarch64 Linux. However, these precompiled gems don't include
the Omnibus library path (`/opt/gitlab/embedded/lib`) as part
of the default `LD_LIBRARY_PATH`, so libraries such as `libarchive`
can't be loaded from Omnibus.

Bundler allows us to ignore the precompiled gems by using
`force_ruby_platform` in the `Gemfile`, so use this feature to
effectively restore the behavior in previous ffi gem versions.

Relates to https://gitlab.com/gitlab-org/omnibus-gitlab/-/issues/8590

Changelog: fixed

diff --git a/config/software/omnibus-gitlab-gems.rb b/config/software/omnibus-gitlab-gems.rb
--- a/config/software/omnibus-gitlab-gems.rb
+++ b/config/software/omnibus-gitlab-gems.rb
@@ -18,7 +18,7 @@
 require "#{Omnibus::Config.project_root}/lib/gitlab/ohai_helper.rb"
 name 'omnibus-gitlab-gems'
 
-default_version '20240110'
+default_version '20240619'
 
 license 'MIT'
 license_file 'LICENSE'
diff --git a/config/templates/omnibus-gitlab-gems/Gemfile b/config/templates/omnibus-gitlab-gems/Gemfile
--- a/config/templates/omnibus-gitlab-gems/Gemfile
+++ b/config/templates/omnibus-gitlab-gems/Gemfile
@@ -8,6 +8,10 @@
 # found with the Ruby interpreter unless `bundle exec` is used.
 source 'https://rubygems.org'
 
+# To ensure LD_LIBRARY_PATH includes /opt/gitlab/embedded/lib avoid
+# the precompiled native gems.
+gem 'ffi', '1.17.0', force_ruby_platform: true
+
 # chef depends on unf_ext. This needs to be listed before Chef
 # since Cinc will look inside the Cinc RubyGems.
 gem 'unf_ext', '0.0.9.1'
diff --git a/config/templates/omnibus-gitlab-gems/Gemfile.lock b/config/templates/omnibus-gitlab-gems/Gemfile.lock
--- a/config/templates/omnibus-gitlab-gems/Gemfile.lock
+++ b/config/templates/omnibus-gitlab-gems/Gemfile.lock
@@ -401,6 +401,7 @@
   chef-zero (= 15.0.11)!
   faraday (= 2.8.1)
   faraday-net_http (= 3.0.2)
+  ffi (= 1.17.0)
   gitlab-ruby-shadow (= 2.5.1)
   inspec-core (= 6.6.0)!
   license_finder (= 7.1.0)