title: Ruby gem with native extensions not working on AWS Lambda
body: <p>I have a ruby script that I am trying to run on AWS Lambda.  How do I get this to use a Ruby gem with native extensions?</p>
  <p>I have installed my Ruby gems through <code>bundle install --deployment</code> and included them in my deployment.  When I run the function on lambda, I get the error:</p>
  <blockquote>
  <p>Ignoring oj-2.18.5 because its extensions are not built. Try: gem pristine oj --version 2.18.5</p>
  <p>Init error when loading handler</p>
  <p>{</p>
  <p>&quot;errorMessage&quot;: &quot;libruby.so.2.5: cannot open shared object file: No such file or directory - /opt/ruby/gems/2.5.0/gems/oj-2.18.5/lib/oj/oj.so&quot;,</p>
  <p>...</p>
  </blockquote>
  <p>I have tried including dependencies both in the lambda code itself and as a lambda layer.  The only thing that changes is the path in the error message.</p>
  <p>Lambda is able to find my ruby gems.  I get a different error when they are in the wrong location.</p>
  <p><code>/opt/ruby/gems/2.5.0/gems/oj-2.18.5/lib/oj/oj.so</code> does exist.</p>
  <p>I have tried this with files generated by <code>bundle install</code> on both Ubuntu and AWS-linux.  On both systems, bundle informs me that it is &quot;Installing oj 2.18.5 with native extensions&quot;.</p>
  <p>If I upload a copy of <code>libruby.so</code> to my lambda, and set the environment variable <code>LD_LIBRARY_PATH</code> to its location and using the set of dependencies installed on the AWS-linux fixes the error listed above, but only to give me an error even more opaque:</p>
  <blockquote>
  <p>/lib64/libc.so.6: version `GLIBC_2.25' not found (required by /opt/ruby/lib/libruby.so.2.5)</p>
  </blockquote>