Skip to content
Permalink
Browse files

Add C extension shared objects to Ruby $LOAD_PATH

We already create a shim script at `/usr/bin/puppet` that adds
`/usr/lib/ruby/vendor_ruby` to Puppet's `$LOAD_PATH` to allow us to use
system (i.e. installed from APT) packages for Puppet, Hiera and Facter.

This is necessary because we run puppet using `rbenv`.

This commit adds a further directory within `vendor_ruby` such that we
can load the shared object (`.so`) files used by system Ruby gems that
act as C extensions. Specifically, we are doing this so that the `gpgme`
Ruby gem (installed from the `ruby-gpgme` APT package) can load this
file:

```
/usr/lib/ruby/vendor_ruby/1.9.1/x86_64-linux/gpgme_n.so
```

We use the `Rbconfig::CONFIG` constants which supply the Ruby ABI
version (`1.9.1` currently) and the system architecture to build the
load path.
  • Loading branch information...
mattbostock committed Sep 19, 2014
1 parent 3c4a2ff commit b7743452875b1dd83fda982e28ae8e776bc3a8b8
Showing with 4 additions and 1 deletion.
  1. +4 −1 modules/puppet/files/usr/bin/puppet
@@ -1,7 +1,10 @@
#!/usr/bin/env ruby

# Allow system package to be used with non-system Ruby.
$LOAD_PATH.unshift('/usr/lib/ruby/vendor_ruby')
$LOAD_PATH.unshift(
'/usr/lib/ruby/vendor_ruby',
"/usr/lib/ruby/vendor_ruby/#{RbConfig::CONFIG["ruby_version"]}/#{RbConfig::CONFIG["arch"]}",
)

require 'puppet/util/command_line'
Puppet::Util::CommandLine.new.execute

0 comments on commit b774345

Please sign in to comment.
You can’t perform that action at this time.